/**
* Message and Spam Filter Plugin - Filtering Functions
*
- * 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 definitely 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$
* @copyright (c) 1999-2005 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @subpackage filters
*/
-@include_once (SM_PATH . 'plugins/filters/config.php');
+/** @ignore */
+if (! defined('SM_PATH')) define('SM_PATH','../../');
+
+/** load globals */
+global $UseSeparateImapConnection,
+ $AllowSpamFilters, $SpamFilters_YourHop, $SpamFilters_ShowCommercial,
+ $SpamFilters_DNScache, $SpamFilters_BulkQuery, $SpamFilters_SharedCache,
+ $SpamFilters_CacheTTL;
+
+/** load default config */
+if (file_exists(SM_PATH . 'plugins/filters/config_default.php')) {
+ include_once (SM_PATH . 'plugins/filters/config_default.php');
+} else {
+ // default config was removed.
+ $UseSeparateImapConnection = false;
+ $AllowSpamFilters = true;
+ $SpamFilters_YourHop = ' ';
+ $SpamFilters_ShowCommercial = false;
+ $SpamFilters_DNScache = array();
+ $SpamFilters_BulkQuery = '';
+ $SpamFilters_SharedCache = true;
+ $SpamFilters_CacheTTL = 7200;
+}
+
+if (file_exists(SM_PATH . 'config/filters_config.php')) {
+ include_once (SM_PATH . 'config/filters_config.php');
+} elseif (file_exists(SM_PATH . 'plugins/filters/config.php')) {
+ include_once (SM_PATH . 'plugins/filters/config.php');
+}
/**
* Init Hooks
*/
function filters_init_hooks () {
global $squirrelmail_plugin_hooks;
- if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
- if (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) {
- sqgetGlobalVar('mailbox',$mailbox,SQ_FORM);
- } else {
+
+ if (! sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) {
$mailbox = 'INBOX';
}
*/
function filters_optpage_register_block() {
global $optpage_blocks, $AllowSpamFilters;
- if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-
+
$optpage_blocks[] = array(
'name' => _("Message Filters"),
'url' => SM_PATH . 'plugins/filters/options.php',
function start_filters() {
global $imapServerAddress, $imapPort, $imap_stream, $imapConnection,
$UseSeparateImapConnection, $AllowSpamFilters;
-
- if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-
+
sqgetGlobalVar('username', $username, SQ_SESSION);
sqgetGlobalVar('key', $key, SQ_COOKIE);
$filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
} else if ($filters[$i]['where'] == 'Message Body') {
$expunge = filter_search_and_delete($imap_stream, 'BODY',
- $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
+ $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge);
} else {
/*
* If it's a normal TO, CC, SUBJECT, or FROM, then handle it
* @param string $what String to search for
* @param string $where_to Folder it will move to
* @param string $user_scan Whether to search all or just unseen
- * @param string $should_expunge
+ * @param string $should_expunge
* @param boolean $where Which part of location to search
* @access private
*/
if ($response == 'OK' && count($ids)) {
if (sqimap_mailbox_exists($imap_stream, $where_to)) {
$should_expunge = true;
- sqimap_msgs_list_move ($imap_stream, $ids, $where_to);
+ sqimap_msgs_list_move ($imap_stream, $ids, $where_to, false);
}
}
}
/**
* Swaps two filters
* @param int $id1 ID of first filter to swap
- * @param int $id2 ID of second filter to swap
+ * @param int $id2 ID of second filter to swap
* @access private
*/
function filter_swap($id1, $id2) {
*/
function update_for_folder ($args) {
- if (!file_exists(SM_PATH . 'plugins/filters/config.php')) return;
-
$old_folder = $args[0];
$new_folder = $args[2];
$action = $args[1];