X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=plugins%2Ffilters%2Foptions.php;h=c4e974511d02e9c64b40c66eb7b98a96b6ca44db;hb=e597520d34f8ca0394e3bde68e7e59593b82bcae;hp=9d658a5c01d0577b6acc1e53201c1396aa306478;hpb=4eee59686ea6b1027411d32b4714e896c5fc6012;p=squirrelmail.git
diff --git a/plugins/filters/options.php b/plugins/filters/options.php
index 9d658a5c..c4e97451 100644
--- a/plugins/filters/options.php
+++ b/plugins/filters/options.php
@@ -1,312 +1,263 @@
$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);
- }
+/**
+ * Message and Spam Filter Plugin - Filtering Options
+ *
+ * @version $Id$
+ * @copyright (c) 1999-2005 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @package plugins
+ * @subpackage filters
+ */
+
+/**
+ * Path for SquirrelMail required files.
+ * @ignore
+ */
+define('SM_PATH','../../');
+
+/* SquirrelMail required files. */
+require_once(SM_PATH . 'include/validate.php');
+include_once(SM_PATH . 'functions/imap.php');
+include_once(SM_PATH . 'plugins/filters/filters.php');
+
+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;
+ }
- 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();
+ sqgetGlobalVar('filter_where', $filter_where, SQ_POST);
+ if (!sqgetGlobalVar('filter_where', $filter_where, SQ_POST)) {
+ do_error("Post error");
+ $complete_post=false;
+ }
- echo ' ' .
- '
'.
- "".
- '' . _("Options") . ' - ' . _("Message Filtering") . ' '.
- '
'.
- '[' . _("New") .
- ' ] - [' . _("Done") . ' ] ' .
- '';
+ sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST);
+ if (!sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST)) {
+ do_error("Post error");
+ $complete_post=false;
+ }
- for ($i=0; $i < count($filters); $i++) {
+ 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);
- $clr = (($i % 2)?$color[0]:$color[9]);
- $fdr = ($folder_prefix)?str_replace($folder_prefix, "", $filters[$i]["folder"]):$filters[$i]["folder"];
- echo "".
- "[" . _("Edit") . ' ]'.
- ' '.
- "[" . _("Delete") . ' ]'.
- ' [';
-
- if (isset($filters[$i + 1])) {
- echo "" . _("Down") . ' ';
- if ($i > 0) {
- echo ' | ';
- }
- }
- if ($i > 0) {
- echo "" . _("Up") . ' ';
+ if (empty($filter_what)) {
+ do_error(_("WARNING! You must enter something to search for."));
+ $action = 'edit';
}
- echo '] - ';
- printf( _("If %s contains %s then move to %s "), _($filters[$i]['where']), $filters[$i]['what'], $fdr );
- 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;
}
- 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 '';
+} 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 ($spam_filters[$Key]['enabled']) {
- echo _("ON");
- } else {
- echo _("OFF");
- }
+ $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( 'div', '[' . _("New") .
+ ' ] - [' . _("Done") . ' ]' ,
+ 'center' ) . ' ';
- echo ' - ';
+ if (isset($action) && ($action == 'add' || $action == 'edit')) {
- if ($spam_filters[$Key]['link']) {
- echo '';
- }
+ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+ $boxes = sqimap_mailbox_list($imapConnection);
- echo $spam_filters[$Key]['name'];
- if ($spam_filters[$Key]['link']) {
- echo ' ';
- }
- echo " \n";
+ for ($a = 0, $cnt = count($boxes); $a < $cnt; $a++) {
+ if (strtolower($boxes[$a]['formatted']) == 'inbox') {
+ unset($boxes[$a]);
}
- echo '';
}
- }
- 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 ''.
- ''.
- ' ';
+ '';
- } 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 ''.
- ''.
- ''.
- ''.
- '' . _("Move spam to:") . ' '.
- '';
-
- for ($i = 0; $i < count($boxes); $i++) {
- if (! in_array('noselect', $boxes[$i]['flags'])) {
- $box = $boxes[$i]['unformatted'];
- $box2 = str_replace(' ', ' ', $boxes[$i]['formatted']);
- if ($filters_spam_folder == $box)
- echo "$box2 \n";
- else
- echo "$box2 \n";
- }
- }
- echo ' '.
- ' '.
- ' '.
- '' .
- _("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:") . ' '.
- ''.
- '' . _("All messages") . ' '.
- '' . _("Only unread messages") . ' ' .
- ' '.
- ' '.
- ' '.
- ''.
- ''.
- _("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.").
- ' ';
-
- $spam_filters = load_spam_filters();
-
- foreach ($spam_filters as $Key => $Value) {
- echo "$Key \n" .
- ' - ';
- if ($spam_filters[$Key]['link']) {
- echo '';
+ 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'] .
- " \n";
+ echo ']';
}
- echo ' '.
- '
'.
- ' '.
- ' ';
+ 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 '