Show global spam score deletion rule, and always show table if we have any global...
authorJamie Cameron <jcameron@webmin.com>
Wed, 27 Feb 2008 01:40:08 +0000 (01:40 +0000)
committerJamie Cameron <jcameron@webmin.com>
Wed, 27 Feb 2008 01:40:08 +0000 (01:40 +0000)
filter/CHANGELOG
filter/filter-lib.pl
filter/index.cgi
filter/lang/en

index 75848b9..ec20ff9 100644 (file)
@@ -16,3 +16,4 @@ Added Module Config options to set the minimum allowed time between autoreplies,
 The default From: address for autoreplies now respects the default address set in the user's address book.
 ---- Changes since 1.330 ----
 Added a filter condition to match mail with a spam score at or above some level.
+If spam deletion above some level level is configured globally or for the user's domain, display a non-editable rule for it.
index 5f33661..0227eca 100644 (file)
@@ -350,6 +350,33 @@ else {
        }
 }
 
+# get_global_spam_delete()
+# Returns the global score above which spam is deleted, typically by a 
+# Virtualmin per-domain procmail file
+sub get_global_spam_delete
+{
+if ($virtualmin_domain_id) {
+       # Read the Virtualmin procmailrc for the domain
+       local $vmpmrc = "$config{'virtualmin_config'}/procmail/".
+                       $virtualmin_domain_id;
+       local @vmrecipes = &procmail::parse_procmail_file($vmpmrc);
+       local ($spamrec, $level) = &spam::find_delete_recipe(\@vmrecipes);
+       if ($spamrec) {
+               return $level;
+               }
+       }
+# Also check the global /etc/procmailrc
+local @recipes = &procmail::parse_procmail_file(
+       $spam::config{'global_procmailrc'});
+local ($spamrec, $level) = &spam::find_delete_recipe(\@recipes);
+if ($spamrec) {
+       return $level;
+       }
+else {
+       return undef;
+       }
+}
+
 sub has_spamassassin
 {
 return &foreign_installed("spam");
index ec3a2f9..fa31a5f 100755 (executable)
@@ -43,8 +43,11 @@ if (&no_user_procmailrc()) {
        }
 
 @filters = &list_filters();
-@links = ( &select_all_link("d"), &select_invert_link("d"),
-          "<a href='edit.cgi?new=1'>$text{'index_add'}</a>" );
+@links = ( );
+if (@filters) {
+       push(@links, &select_all_link("d"), &select_invert_link("d"));
+       }
+push(@links, "<a href='edit.cgi?new=1'>$text{'index_add'}</a>");
 ($auto) = grep { $_->{'actionreply'} } @filters;
 if (&can_simple_autoreply() && !$auto) {
        push(@links, "<a href='edit_auto.cgi'>$text{'index_addauto'}</a>");
@@ -55,7 +58,7 @@ if (&can_simple_forward() && !$fwd) {
        }
 
 @folders = &mailbox::list_folders();
-if (@filters) {
+if (@filters || &get_global_spamassassin()) {
        # Show table of filters
        print &ui_form_start("delete.cgi", "post");
        @tds = ( "width=5", "width=50%", "width=50%", "width=32" );
@@ -72,6 +75,16 @@ if (@filters) {
                        [ "", $text{'index_calways'}, $text{'index_aspam'},
                          @filters > 1 ? ( "" ) : ( ) ],
                        \@tds);
+               # Delete level
+               $spamlevel = &get_global_spam_delete();
+               if ($spamlevel) {
+                       print &ui_columns_row(
+                               [ "", &text('index_clevel', $spamlevel),
+                                     $text{'index_athrow'},
+                                 @filters > 1 ? ( "" ) : ( ) ],
+                               \@tds);
+                       }
+               # Delivery path
                $spamfile = &get_global_spam_path();
                if ($spamfile) {
                        $folder = &file_to_folder($spamfile, \@folders, 0, 1);
@@ -145,32 +158,9 @@ else {
        if (@pmrc) {
                print "<b>$text{'index_none2'}</b><p>\n";
                }
-       elsif (&get_global_spamassassin()) {
-               $spamfile = &get_global_spam_path();
-               if ($spamfile) {
-                       $folder = &file_to_folder($spamfile, \@folders, 0, 1);
-                       print "<b>";
-                       $id = &mailbox::folder_name($folder);
-                       if ($folder->{'fake'}) {
-                               print &text('index_none4',
-                                           "<u>$folder->{'name'}</u>");
-                               }
-                       else {
-                               print &text('index_none4',
-                                   "<a href='../mailbox/index.cgi?id=$id'>".
-                                   "$folder->{'name'}</a>");
-                               }
-                       print "</b><p>\n";
-                       }
-               else {
-                       print "<b>$text{'index_none3'}</b><p>\n";
-                       }
-               }
        else {
                print "<b>$text{'index_none'}</b><p>\n";
                }
-       shift(@links);
-       shift(@links);
        print &ui_links_row(\@links);
        }
 
index 741c44b..3b8db75 100644 (file)
@@ -4,9 +4,6 @@ index_action=Filter action
 index_move=Move
 index_none=You do not have any mail filters defined yet. All email will be delivered to your Inbox.
 index_none2=None of your existing Procmail rules are simple enough to display here.
-index_none3=You do not have any mail filters defined yet. All email will be delivered to your Inbox, after spam classification.
-index_none4=You do not have any mail filters defined yet. All email will be deliverted to your Inbox, except spam which will be sent to the folder $1.
-index_none5=You do not have any mail filters defined yet. All email will be deliverted to your Inbox, except spam which will be sent to the file $1.
 index_add=Add a new email filter.
 index_addauto=Quick automatic reply setup.
 index_addfwd=Quick forwarding setup.