X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Ffilters%2Foptions.php;h=c5d076e35e030bf30ff28151a40d393a7481c467;hp=5160a93f664febc13094634a5b34ea917f12d9e3;hb=0a1dc88e11c9c6b1734eaa35849e3476dc425c6d;hpb=618d1e63258ce8902efd1b311e3c9acbd80647f1 diff --git a/plugins/filters/options.php b/plugins/filters/options.php index 5160a93f..c5d076e3 100644 --- a/plugins/filters/options.php +++ b/plugins/filters/options.php @@ -1,318 +1,262 @@ - * Tyler Akins - * Brent Bice - * (c) 2000 (GNU GPL - see ../../COPYING) - * - * This plugin filters your inbox into different folders based upon given - * criteria. It is most useful for people who are subscibed to mailing lists - * to help organize their messages. The argument stands that filtering is - * not the place of the client, which is why this has been made a plugin for - * SquirrelMail. You may be better off using products such as Sieve or - * Procmail to do your filtering so it happens even when SquirrelMail isn't - * running. - * - * If you need help with this, or see improvements that can be made, please - * email me directly at the address above. I definately welcome suggestions - * and comments. This plugin, as is the case with all SquirrelMail plugins, - * is not directly supported by the developers. Please come to me off the - * mailing list if you have trouble with it. - * - * Also view plugins/README.plugins for more information. - * - */ - chdir('..'); - require_once('../src/validate.php'); - require_once('../functions/page_header.php'); - require_once('../functions/imap.php'); - require_once('../src/load_prefs.php'); - - global $AllowSpamFilters; - - displayPageHeader($color, 'None'); - - if (isset($filter_submit)) { - if (!isset($theid)) $theid = 0; - $filter_what = str_replace(',', ' ', $filter_what); - $filter_what = str_replace("\\\\", "\\", $filter_what); - $filter_what = str_replace("\\\"", "\"", $filter_what); - $filter_what = str_replace("\"", """, $filter_what); - - 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($spam_submit) && $AllowSpamFilters) { - $spam_filters = load_spam_filters(); - setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set); - setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set); - foreach ($spam_filters as $Key => $Value) - { - $input = $spam_filters[$Key]['prefname'] . '_set'; - setPref($data_dir, $username, $spam_filters[$Key]['prefname'], - $$input); - } +/** + * Message and Spam Filter Plugin - Filtering Options + * + * Copyright (c) 1999-2004 The SquirrelMail Project Team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * This plugin filters your inbox into different folders based upon given + * criteria. It is most useful for people who are subscibed to mailing lists + * to help organize their messages. The argument stands that filtering is + * not the place of the client, which is why this has been made a plugin for + * SquirrelMail. You may be better off using products such as Sieve or + * Procmail to do your filtering so it happens even when SquirrelMail isn't + * running. + * + * If you need help with this, or see improvements that can be made, please + * email me directly at the address above. I definately welcome suggestions + * and comments. This plugin, as is the case with all SquirrelMail plugins, + * is not directly supported by the developers. Please come to me off the + * mailing list if you have trouble with it. + * + * Also view plugins/README.plugins for more information. + * + * @version $Id$ + * @package plugins + * @subpackage filters + */ + +/** + * Path for SquirrelMail required files. + * @ignore + */ +define('SM_PATH','../../'); + +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/page_header.php'); +require_once(SM_PATH . 'functions/imap.php'); +require_once(SM_PATH . 'functions/imap_mailbox.php'); +require_once(SM_PATH . 'include/load_prefs.php'); +require_once(SM_PATH . 'plugins/filters/filters.php'); + +global $AllowSpamFilters; + +displayPageHeader($color, 'None'); + +/* get globals */ +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('key', $key, SQ_COOKIE); +sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); + +sqgetGlobalVar('theid', $theid); +sqgetGlobalVar('action', $action, SQ_GET); + +if (sqgetGlobalVar('filter_submit',$filter_submit,SQ_POST)) { + + if(! isset($theid) ) $theid = 0; + + $complete_post=true; + + // 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; + } + + sqgetGlobalVar('filter_where', $filter_where, SQ_POST); + if (!sqgetGlobalVar('filter_where', $filter_where, SQ_POST)) { + do_error("Post error"); + $complete_post=false; + } + + sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST); + if (!sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST)) { + do_error("Post error"); + $complete_post=false; + } + + 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 (($filter_where == 'Header') && (strchr($filter_what,':') == '')) { + do_error(_("WARNING! Header filters should be of the format \"Header: value\"")); + $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"; } - 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(); - - echo '
' . - ''. - "
". - '
' . _("Options") . ' - ' . _("Message Filtering") . '
'. - '
'. - '
[' . _("New") . - '] - [' . _("Done") . ']

' . - ''; - - for ($i=0; $i < count($filters); $i++) { - if ($i % 2 == 0) { - $clr = $color[0]; - } else { - $clr = $color[9]; - } - - $fdr = ($folder_prefix)?str_replace($folder_prefix, "", $filters[$i]["folder"]):$filters[$i]["folder"]; - - echo "'; - - } - - 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 '
'. - ''. - ''. - '
 
'; - - if ($AllowSpamFilters) { - - echo "". - ''. - '
' . _("Spam Filtering") . '
'; - if (! isset($action) || $action != 'spam') { - - 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(); - - foreach ($spam_filters as $Key => $Value) { - echo '\n"; - } - echo '
'; - - if ($spam_filters[$Key]['enabled']) { - echo _("ON"); - } else { - echo _("OFF"); - } - - echo ' - '; - - if ($spam_filters[$Key]['link']) { - echo ''; - } - - echo $spam_filters[$Key]['name']; - if ($spam_filters[$Key]['link']) { - echo ''; - } - echo "
'; - } + $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', '', '', '', 'border="0" cellpadding="2" cellspacing="0"' ) . + html_tag( 'tr' ) . + html_tag( 'th', _("What to Scan:"), 'right', '', '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); $boxes = sqimap_mailbox_list($imapConnection); sqimap_logout($imapConnection); if ( !isset($theid) ) { $theid = count($filters); } - echo '
'. - '
'. - '
'. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. + ''. + html_tag( 'tr' ) . + html_tag( 'td', _("Move to:"), 'left' ) . + html_tag( 'td', '', 'left' ) . + ''. + ''. - ''. - ''. + ''. + ''. + ''. '
 '. - ''; $L = isset($filters[$theid]['where']); $sel = (($L && $filters[$theid]['where'] == 'From')?'selected':''); - echo "'; - + echo "'; + $sel = (($L && $filters[$theid]['where'] == 'To')?'selected':''); - echo "'; + echo "'; $sel = (($L && $filters[$theid]['where'] == 'Cc')?'selected':''); - echo "'; + echo "'; $sel = (($L && $filters[$theid]['where'] == 'To or Cc')?'selected':''); - echo "'; + echo "'; $sel = (($L && $filters[$theid]['where'] == 'Subject')?'selected':''); - echo "'; + echo "'; + + $sel = (($L && $filters[$theid]['where'] == 'Header')?'selected':''); + echo "'; echo ''. - '
'. - _("Contains:"). - ''. - ''. - '
'. - _("Move to:"). - ''. - ''. - '
'. - ''. - "". + '\n". + '\n". ''. - '
'; + ''; - } 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"; + if ($i > 0) { + echo "" . _("Up") . ''; } - 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 ''; - } - echo $spam_filters[$Key]['name']; - if ($spam_filters[$Key]['link']) { - echo ''; - } - 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'].'', + ''.imap_utf7_decode_local($fdr).''); + echo ''; - sqimap_logout($imapConnection); } + echo ''. + html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', ' ', 'left' ) + ) , + 'center', '', 'width="80%" border="0" cellpadding="2" cellspacing="0"' ); + echo ''; ?> \ No newline at end of file