Match type selection for filters

This commit is contained in:
Jamie Cameron
2009-03-27 18:57:12 +00:00
parent d2616011e0
commit 2f065bb32b
11 changed files with 58 additions and 16 deletions

View File

@@ -21,3 +21,4 @@ If spam deletion above some level level is configured globally or for the user's
Autoreply messages containing non-ASCII characters are now properly quoted-printable encoded.
---- Changes since 1.400 ----
Filters that deliver to mbox-format folders now have locking enabled.
Creation of filters that match headers is now less error-prone, due to a new menu for selecting if it should match the start, end or any part of the header.

View File

@@ -51,11 +51,28 @@ print &ui_table_row(
&ui_textbox("condlevel", $filter->{'condlevel'}, 4), undef, \@tds);
# Check some header
@headers = ( "From", "To", "Subject", "Cc", "Reply-To" );
@headers = ( "From", "To", "Subject", "Cc", "Reply-To", "List-Id" );
$common = &indexoflc($filter->{'condheader'}, @headers) >= 0;
if ($filter->{'condvalue'} =~ /^\.\*(.*)\$$/) {
# Ends with
$condvalue = $1;
$condmode = 2;
}
elsif ($filter->{'condvalue'} =~ /^\.\*(.*)\.\*$/ ||
$filter->{'condvalue'} =~ /^\.\*(.*)$/) {
# Contains
$condvalue = $1;
$condmode = 1;
}
elsif ($filter->{'condvalue'} =~ /^(.*)\.\*$/ ||
$filter->{'condvalue'} =~ /^(.*)$/) {
# Starts with
$condvalue = $1;
$condmode = 0;
}
print &ui_table_row(
&ui_oneradio("cmode", 4, $text{'edit_cmode4'}, $cmode == 4),
&text('edit_cheader',
&text('edit_cheader2',
&ui_select("condmenu", $cmode != 4 ? "From" :
$common ? $filter->{'condheader'} : "",
[ (map { [ $_ ] } @headers),
@@ -65,8 +82,11 @@ print &ui_table_row(
&ui_textbox("condheader",
$common ? "" : $filter->{'condheader'}, 20,
$cmode != 4 || $common),
&ui_textbox("condvalue",
$filter->{'condvalue'}, 40)),
&ui_select("condmode", $condmode,
[ [ 0, $text{'edit_modestart'} ],
[ 1, $text{'edit_modecont'} ],
[ 2, $text{'edit_modeend'} ] ]),
&ui_textbox("condvalue", $condvalue, 40)),
undef, \@tds);
# Smaller

View File

@@ -482,9 +482,23 @@ elsif ($f->{'condlevel'}) {
$cond = &text('index_clevel', $f->{'condlevel'});
}
elsif ($f->{'condheader'}) {
$cond = &text('index_cheader',
"<tt>".&html_escape($f->{'condheader'})."</tt>",
"<tt>".&html_escape($f->{'condvalue'})."</tt>");
if ($f->{'condvalue'} =~ /^\.\*(.*)\$$/) {
$cond = &text('index_cheader2',
"<tt>".&html_escape($f->{'condheader'})."</tt>",
"<tt>".&html_escape($1)."</tt>");
}
elsif ($f->{'condvalue'} =~ /^\.\*(.*)\.\*$/ ||
$f->{'condvalue'} =~ /^\.\*(.*)$/) {
$cond = &text('index_cheader1',
"<tt>".&html_escape($f->{'condheader'})."</tt>",
"<tt>".&html_escape($1)."</tt>");
}
elsif ($f->{'condvalue'} =~ /^(.*)\.\*$/ ||
$f->{'condvalue'} =~ /^(.*)$/) {
$cond = &text('index_cheader0',
"<tt>".&html_escape($f->{'condheader'})."</tt>",
"<tt>".&html_escape($1)."</tt>");
}
}
elsif ($f->{'condtype'} eq '<' || $f->{'condtype'} eq '>') {
$cond = &text('index_csize'.$f->{'condtype'},

View File

@@ -41,7 +41,6 @@ edit_title2=Edici
edit_header1=Condició del filtre
edit_cmode0=Tot el correu
edit_cmode4=Basat en la capçalera
edit_cheader=La capçalera $1$2 ha de coincidir $3
edit_cmode3=El correu és més petit de
edit_cmode2=El correu és més gran de
edit_cmode5=Correu classificat com a spam

View File

@@ -24,7 +24,6 @@ edit_amode5=Vykonat klasifikaci na nevy
edit_amode6=Odeslat automatickou odpověď
edit_amode7=Uložit nové jméno adresáře
edit_cbody=Aplikovat na tělo zprávy
edit_cheader=Hlavička $1$2 se musí shodnout s $3
edit_cmode0=Všechny emaily
edit_cmode1=Na základě regulérního výrazu
edit_cmode2=Email větší než

View File

@@ -24,7 +24,6 @@ edit_amode5=F&#252;hre Spam Klassifizierung durch
edit_amode6=Sende automatische Antwort
edit_amode7=Speichere in neuem Ordner mit dem Namen
edit_cbody=Anwenden auf Nachrichten Body
edit_cheader=Header $1$2 muss mit $3 &#252;bereinstimmen
edit_cmode0=Alle E-Mail
edit_cmode1=Basierend auf regul&#228;rem Ausdruck
edit_cmode2=E-Mail gr&#246;sser als

View File

@@ -35,7 +35,6 @@ edit_title2=
edit_header1=Συνθήκη για φίλτρο
edit_cmode0=Όλα τα email
edit_cmode4=Βάση της επικεφαλίδας
edit_cheader=Η επικεφαλίδα $1$2 θα πρέπει να ταιριάζει με $3
edit_cmode3=Το μέγεθος του email είναι μικρότερο από
edit_cmode2=Το μέγεθος του email είναι μεγαλύτερο από
edit_cmode5=Κατάταξη email ως spam

View File

@@ -9,7 +9,12 @@ index_addauto=Quick automatic reply setup.
index_addfwd=Quick forwarding setup.
index_cspam=Email is spam
index_clevel=Spam score is at least $1
index_cheader=Header $1 matches $2
index_cheader0=Header $1 must start with $2
index_cheader1=Header $1 must contain $2
index_cheader2=Header $1 must end with $2
edit_modestart=starts with
edit_modecont=contains
edit_modeend=ends with
index_cre=Headers match $1
index_cre2=Body matches $1
index_calways=Always
@@ -41,7 +46,7 @@ edit_title2=Edit Filter
edit_header1=Condition for filter
edit_cmode0=All email
edit_cmode4=Based on header
edit_cheader=Header $1$2 must match $3
edit_cheader2=Header $1$2 $3 $4
edit_cmode3=Email smaller than
edit_cmode2=Email larger than
edit_cmode5=Email classified as spam

View File

@@ -35,7 +35,6 @@ edit_title2=Muokkaa suodatinta
edit_header1=Suodattimen ehto
edit_cmode0=Kaikki sähköpostit
edit_cmode4=Täsmäävä otsake
edit_cheader=Otsakkeen $1$2 täytyy täsmätä $3
edit_cmode3=Sähköposti pienempi kuin
edit_cmode2=Sähköposti suurempi kuin
edit_cmode5=Sähköposti luokiteltu roskapostiksi

View File

@@ -24,7 +24,6 @@ edit_amode5=Maak een spam classificatie
edit_amode6=Stuur automatisch antwoord
edit_amode7=Opslaan naar nieuw folder genaamd
edit_cbody=Toevoegen aan berichten body
edit_cheader=Header $1$2 moet overeenkomen met $3
edit_cmode0=Alle email
edit_cmode1=Gebaseerd op regulaire expressies
edit_cmode2=Email groter dan

View File

@@ -49,7 +49,15 @@ else {
$filter->{'condheader'} = $in{'condmenu'} || $in{'condheader'};
$filter->{'condheader'} =~ /^[a-zA-Z0-9\-]+$/ ||
&error($text{'save_econdheader'});
$filter->{'condvalue'} = $in{'condvalue'};
if ($in{'condmode'} == 0) {
$filter->{'condvalue'} = $in{'condvalue'};
}
elsif ($in{'condmode'} == 1) {
$filter->{'condvalue'} = ".*".$in{'condvalue'}.".*";
}
else {
$filter->{'condvalue'} = ".*".$in{'condvalue'}."\$";
}
}
elsif ($in{'cmode'} == 3) {
# Smaller than some size