X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Ffilters%2Foptions.php;h=9cc1e54e93e4858c0c5c6043db046314920dc2fd;hp=9d658a5c01d0577b6acc1e53201c1396aa306478;hb=3ba5c6063eb9282838b862d4f206266d0034e905;hpb=4eee59686ea6b1027411d32b4714e896c5fc6012 diff --git a/plugins/filters/options.php b/plugins/filters/options.php index 9d658a5c..9cc1e54e 100644 --- a/plugins/filters/options.php +++ b/plugins/filters/options.php @@ -1,312 +1,257 @@ $Value) { - $input = $spam_filters[$Key]['prefname'] . '_set'; - setPref($data_dir, $username, $spam_filters[$Key]['prefname'], - $$input); - } - } elseif (isset($action) && $action == 'delete') { - remove_filter($theid); - } elseif (isset($action) && $action == 'move_up') { - filter_swap($theid, $theid - 1); - } elseif (isset($action) && $action == 'move_down') { - filter_swap($theid, $theid + 1); - } - if ($AllowSpamFilters) { - $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder'); - $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan'); - } - $filters = load_filters(); +/** + * Message and Spam Filter Plugin - Filtering Options + * + * @copyright © 1999-2007 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage filters + */ - echo '
' . - ''. - "
". - '
' . _("Options") . ' - ' . _("Message Filtering") . '
'. - '
'. - '
[' . _("New") . - '] - [' . _("Done") . ']

' . - ''; +/** + * Include the SquirrelMail initialization file. + */ +require('../../include/init.php'); +include_once(SM_PATH . 'functions/imap_general.php'); +include_once(SM_PATH . 'functions/forms.php'); +include_once(SM_PATH . 'plugins/filters/filters.php'); - for ($i=0; $i < count($filters); $i++) { +displayPageHeader($color); - $clr = (($i % 2)?$color[0]:$color[9]); - $fdr = ($folder_prefix)?str_replace($folder_prefix, "", $filters[$i]["folder"]):$filters[$i]["folder"]; - echo "'; +/* get globals */ +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); - } - echo '
". - "[" . _("Edit") . ']'. - ''. - "[" . _("Delete") . ']'. - '['; - - if (isset($filters[$i + 1])) { - echo "" . _("Down") . ''; - if ($i > 0) { - echo ' | '; - } - } - if ($i > 0) { - echo "" . _("Up") . ''; - } - echo '] - '; - printf( _("If %s contains %s then move to %s"), _($filters[$i]['where']), $filters[$i]['what'], $fdr ); - echo '
'. - ''. - ''. - '
 
'; +sqgetGlobalVar('theid', $theid); +sqgetGlobalVar('action', $action, SQ_GET); +if (sqgetGlobalVar('filter_submit',$filter_submit,SQ_POST)) { - if ($AllowSpamFilters) { + if(! isset($theid) ) $theid = 0; - echo "". - ''. - '
' . _("Spam Filtering") . '
'; - if (! isset($action) || $action != 'spam') { + $complete_post=true; - echo '

[' . _("Edit") . ']
'; - printf( _("Spam is sent to %s"), ($filters_spam_folder?$filters_spam_folder:_("[not set yet]") ) ); - echo '
'; - printf( _("Spam scan is limited to %s"), (($filters_spam_scan == 'new')?_("New Messages Only"):_("All Messages") ) ); - echo '

'. - ""; - - $spam_filters = load_spam_filters(); + // FIXME: write human readable error messages + sqgetGlobalVar('filter_what', $filter_what, SQ_POST); + if (!sqgetGlobalVar('filter_what', $filter_what, SQ_POST)) { + do_error("Post error"); + $complete_post=false; + } - foreach ($spam_filters as $Key => $Value) { - echo '\n"; - } - echo '
'; + sqgetGlobalVar('filter_where', $filter_where, SQ_POST); + if (!sqgetGlobalVar('filter_where', $filter_where, SQ_POST)) { + do_error("Post error"); + $complete_post=false; + } - if ($spam_filters[$Key]['enabled']) { - echo _("ON"); - } else { - echo _("OFF"); - } + sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST); + if (!sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST)) { + do_error("Post error"); + $complete_post=false; + } - echo ' - '; + if ($complete_post) { + $filter_what = str_replace(',', ' ', $filter_what); + $filter_what = str_replace("\\\\", "\\", $filter_what); + $filter_what = str_replace("\\\"", '"', $filter_what); + $filter_what = str_replace('"', '"', $filter_what); - if ($spam_filters[$Key]['link']) { - echo ''; - } + if (empty($filter_what)) { + do_error(_("WARNING! You must enter something to search for.")); + $action = 'edit'; + } - echo $spam_filters[$Key]['name']; - if ($spam_filters[$Key]['link']) { - echo ''; - } - echo "
'; + if (($filter_where == 'Header') && (strchr($filter_what,':') == '')) { + do_error(_("WARNING! Header filters should be of the format "Header: value"")); + $action = 'edit'; } + if ($action != 'edit') { + setPref($data_dir, $username, 'filter'.$theid, $filter_where.','.$filter_what.','.$filter_folder); + } + $filters[$theid]['where'] = $filter_where; + $filters[$theid]['what'] = $filter_what; + $filters[$theid]['folder'] = $filter_folder; } +} elseif (isset($action) && $action == 'delete') { + remove_filter($theid); +} elseif (isset($action) && $action == 'move_up') { + filter_swap($theid, $theid - 1); +} elseif (isset($action) && $action == 'move_down') { + filter_swap($theid, $theid + 1); +} elseif (sqgetGlobalVar('user_submit',$user_submit,SQ_POST)) { + sqgetGlobalVar('filters_user_scan_set',$filters_user_scan_set,SQ_POST); + setPref($data_dir, $username, 'filters_user_scan', $filters_user_scan_set); + echo '
'._("Saved Scan type")."
\n"; +} + + $filters = load_filters(); + $filters_user_scan = getPref($data_dir, $username, 'filters_user_scan'); + + echo html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', + '
' . _("Options") . ' - ' . _("Message Filtering") . '
' , + 'left', $color[0] + ) + ), + 'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"' + ) . + '
'. + html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="0"' ) . + html_tag( 'tr' ) . + html_tag( 'th', _("What to Scan:"), 'right', '', 'style="white-space: nowrap;"' ) . + html_tag( 'td', '', 'left' ) . + ''. + ''. + html_tag( 'td', '', 'left' ) . + ''. + '
'. + + html_tag( 'div', '[' . _("New") . + '] - [' . _("Done") . ']' , + 'center' ) . '
'; if (isset($action) && ($action == 'add' || $action == 'edit')) { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); + + $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); + + for ($a = 0, $cnt = count($boxes); $a < $cnt; $a++) { + if (strtolower($boxes[$a]['formatted']) == 'inbox') { + unset($boxes[$a]); + } + } + sqimap_logout($imapConnection); if ( !isset($theid) ) { $theid = count($filters); } - echo '
'. - '
'. - '
'. - ''. - ''. - ''. ''. - ''. - ''. - ''. ''. - ''. - ''. - ''. ''. '
 '. - ''; $L = isset($filters[$theid]['where']); - $sel = (($L && $filters[$theid]['where'] == 'From')?'selected':''); - echo "'; + $sel = (($L && $filters[$theid]['where'] == 'From')?' selected="selected"':''); + echo "'; + + $sel = (($L && $filters[$theid]['where'] == 'To')?' selected="selected"':''); + echo "'; + + $sel = (($L && $filters[$theid]['where'] == 'Cc')?' selected="selected"':''); + echo "'; + + $sel = (($L && $filters[$theid]['where'] == 'To or Cc')?' selected="selected"':''); + echo "'; - $sel = (($L && $filters[$theid]['where'] == 'To')?'selected':''); - echo "'; + $sel = (($L && $filters[$theid]['where'] == 'Subject')?' selected="selected"':''); + echo "'; - $sel = (($L && $filters[$theid]['where'] == 'Cc')?'selected':''); - echo "'; + $sel = (($L && $filters[$theid]['where'] == 'Message Body')?' selected="selected"':''); + echo "'; - $sel = (($L && $filters[$theid]['where'] == 'To or Cc')?'selected':''); - echo "'; + $sel = (($L && $filters[$theid]['where'] == 'Header and Body')?' selected="selected"':''); + echo "'; - $sel = (($L && $filters[$theid]['where'] == 'Subject')?'selected':''); - echo "'; + $sel = (($L && $filters[$theid]['where'] == 'Header')?' selected="selected"':''); + echo "'; echo ''. '
'. - _("Contains:"). - ''. - ''. + echo '" />'. '
'. - _("Move to:"). - ''. + html_tag( 'tr' ) . + html_tag( 'td', _("Move to:"), 'left' ) . + html_tag( 'td', '', 'left' ) . ''. - ''. + ''. + ''. '
'. - ''. - "". + '\n". + addHidden('theid', $theid). '
'. - '
'; + ''; - } else if (isset($action) && $action == 'spam' && $AllowSpamFilters) { - $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); - $boxes = sqimap_mailbox_list($imapConnection); - sqimap_logout($imapConnection); - for ($i = 0; $i < count($boxes) && $filters_spam_folder == ''; $i++) { - if ($boxes[$i]['flags'][0] != 'noselect' && - $boxes[$i]['flags'][1] != 'noselect' && - $boxes[$i]['flags'][2] != 'noselect') { - $filters_spam_folder = $boxes[$i]['unformatted']; - } - } + } - echo '
'. - '
'. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''; - - $spam_filters = load_spam_filters(); - - foreach ($spam_filters as $Key => $Value) { - echo "\n" . - '\n"; + echo ']'; } - echo ''. - '
' . _("Move spam to:") . ''. - '
' . - _("Moving spam directly to the trash may not be a good idea at first, since messages from friends and mailing lists might accidentally be marked as spam. Whatever folder you set this to, make sure that it gets cleaned out periodically, so that you don't have an excessively large mailbox hanging around.") . - '
' . _("What to Scan:") . ''. - '
'. - _("The more messages you scan, the longer it takes. I would suggest that you scan only new messages. If you make a change to your filters, I would set it to scan all messages, then go view my INBOX, then come back and set it to scan only new messages. That way, your new spam filters will be applied and you'll scan even the spam you read with the new filters."). - '
$Key - '; - if ($spam_filters[$Key]['link']) { - echo ''; +if (count($filters)) { + echo html_tag( 'table', '', 'center', '', 'border="0" cellpadding="3" cellspacing="0"' ); + + for ($i=0, $num = count($filters); $i < $num; $i++) { + + $clr = (($i % 2)?$color[0]:$color[9]); + $fdr = ($folder_prefix)?str_replace($folder_prefix, "", $filters[$i]["folder"]):$filters[$i]["folder"]; + echo html_tag( 'tr', '', '', $clr ) . + html_tag( 'td', + '' . + "[" . _("Edit") . ']'. + '' , + 'left' ) . + html_tag( 'td', + '' . + "[" . _("Delete") . ']'. + '' , + 'left' ); + + if ($num > 1) { + echo html_tag( 'td', '', 'center' ) . '['; + if (isset($filters[$i + 1])) { + echo "" . _("Down") . ''; + if ($i > 0) { + echo ' | '; + } } - echo $spam_filters[$Key]['name']; - if ($spam_filters[$Key]['link']) { - echo ''; + if ($i > 0) { + echo "" . _("Up") . ''; } - echo '
' . - $spam_filters[$Key]['comment'] . - "
'. - '
'. - '
'; + echo html_tag( 'td', '-', 'left' ) . + html_tag( 'td', '', 'left' ); + printf( _("If %s contains %s then move to %s"), + ''.$filters[$i]['where'].'', + ''.$filters[$i]['what'].'', + ''.htmlspecialchars(imap_utf7_decode_local($fdr)).''); + echo ''; - sqimap_logout($imapConnection); } -?> + echo ''; +} + echo html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', ' ', 'left' ) + ) , + 'center', '', 'width="80%" border="0" cellpadding="2" cellspacing="0"' ); + echo '';