1#!/usr/local/bin/perl 2# Show a table of simple actions 3 4require './filter-lib.pl'; 5&ui_print_header(undef, $text{'index_title'}, "", undef, 0, 1); 6 7if (&get_product_name() eq 'webmin') { 8 &ui_print_endpage($text{'index_nowebmin'}); 9 } 10 11# Warn if procmail is not installed 12if ($config{'warn_procmail'} && !&has_command("procmail")) { 13 print "$text{'index_warn'}<p>\n"; 14 } 15 16# Check for an override alias 17$alias = &get_override_alias(); 18if ($alias) { 19 # Got one .. but does it deliver locally 20 $noat = $remote_user; 21 $noat =~ s/\@/-/g; 22 @values = @{$alias->{'values'}}; 23 ($tome) = grep { $_ eq "\\$remote_user" || 24 $_ eq "\\$noat" } @values; 25 if ($tome) { 26 @values = grep { $_ ne $tome } @values; 27 $msg = 'index_aliasme'; 28 } 29 else { 30 $msg = 'index_alias'; 31 } 32 print "<b>$text{$msg}</b><br>\n"; 33 print "<ul>\n"; 34 foreach $dest (&describe_alias_dest(\@values)) { 35 print "<li>$dest\n"; 36 } 37 print "</ul>\n"; 38 } 39 40# Check if /etc/procmailrc forces local delivery 41if (&no_user_procmailrc()) { 42 print "<b>",$text{'index_force'},"</b><p>\n"; 43 } 44 45@filters = &list_filters(); 46@links = ( ); 47if (@filters) { 48 push(@links, &select_all_link("d"), &select_invert_link("d")); 49 } 50push(@links, &ui_link("edit.cgi?new=1",$text{'index_add'})); 51($auto) = grep { $_->{'actionreply'} } @filters; 52if (&can_simple_autoreply() && !$auto) { 53 push(@links, &ui_link("edit_auto.cgi",$text{'index_addauto'})); 54 } 55($fwd) = grep { $_->{'actiontype'} eq '!' } @filters; 56if (&can_simple_forward() && !$fwd) { 57 push(@links, &ui_link("edit_forward.cgi",$text{'index_addfwd'})); 58 } 59 60@folders = &mailbox::list_folders(); 61if (@filters || &get_global_spamassassin()) { 62 # Show table of filters 63 print &ui_form_start("delete.cgi", "post"); 64 @tds = ( "width=5", "width=50%", "width=50%", "width=32" ); 65 print &ui_links_row(\@links); 66 print &ui_columns_start([ "", 67 $text{'index_condition'}, 68 $text{'index_action'}, 69 @filters > 1 ? ( $text{'index_move'} ) : ( ), 70 ], 100, 0, \@tds); 71 72 # Add a magic non-editable row(s) for global spamassassin run 73 if (&get_global_spamassassin()) { 74 print &ui_columns_row( 75 [ "", $text{'index_calways'}, $text{'index_aspam'}, 76 @filters > 1 ? ( "" ) : ( ) ], 77 \@tds); 78 # Delete level 79 $spamlevel = &get_global_spam_delete(); 80 if ($spamlevel) { 81 print &ui_columns_row( 82 [ "", &text('index_clevel', $spamlevel), 83 $text{'index_athrow'}, 84 @filters > 1 ? ( "" ) : ( ) ], 85 \@tds); 86 } 87 # Delivery path 88 $spamfile = &get_global_spam_path(); 89 if ($spamfile) { 90 $folder = &file_to_folder($spamfile, \@folders, 0, 1); 91 $id = &mailbox::folder_name($folder); 92 if ($folder->{'fake'}) { 93 $sflink = "<u>$folder->{'name'}</u>"; 94 } 95 else { 96 $sflink = 97 "<a href='../mailbox/index.cgi?id=$id'>". 98 "$folder->{'name'}</a>"; 99 } 100 print &ui_columns_row( 101 [ "", $text{'index_cspam'}, 102 &text('index_afolder', $sflink), 103 @filters > 1 ? ( "" ) : ( ) ], 104 \@tds); 105 } 106 } 107 108 # Show editable rows 109 foreach $f (@filters) { 110 # Work out nice condition and action descriptions 111 local $cond; 112 ($cond, $lastalways) = &describe_condition($f); 113 $cond = &ui_link("edit.cgi?idx=$f->{'index'}",$cond); 114 local $action = &describe_action($f, \@folders); 115 116 # Create mover links 117 local $mover; 118 if ($f eq $filters[0]) { 119 $mover .= "<img src=images/gap.gif alt=' '>"; 120 } 121 else { 122 $mover .= "<a href='up.cgi?idx=$f->{'index'}'>". 123 "<img src=images/up.gif border=0 alt='Up'></a>"; 124 } 125 if ($f eq $filters[$#filters]) { 126 $mover .= "<img src=images/gap.gif alt=' '>"; 127 } 128 else { 129 $mover .= "<a href='down.cgi?idx=$f->{'index'}'>". 130 "<img src=images/down.gif border=0 alt='Down'></a>"; 131 } 132 133 # Show the row 134 print &ui_checked_columns_row( 135 [ $cond, 136 $action, 137 @filters > 1 ? ( $mover ) : ( ) ], 138 \@tds, "d", $f->{'index'} 139 ); 140 141 } 142 143 # Add a magic non-editable row for default delivery 144 if (!$lastalways) { 145 print &ui_columns_row( 146 [ "", $text{'index_calways'}, $text{'index_adefault'}, 147 @filters > 1 ? ( "" ) : ( ) ], 148 \@tds); 149 } 150 151 print &ui_columns_end(); 152 print &ui_links_row(\@links); 153 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]); 154 } 155else { 156 # Tell the user there are none 157 @pmrc = &procmail::get_procmailrc(); 158 if (@pmrc) { 159 print "<b>$text{'index_none2'}</b><p>\n"; 160 } 161 else { 162 print "<b>$text{'index_none'}</b><p>\n"; 163 } 164 print &ui_links_row(\@links); 165 } 166 167&ui_print_footer("/", $text{'index'}); 168 169