X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Ffilters%2Fsetup.php;h=782e1ac587bce7efa62ea514c3b19e0c33e4726d;hp=19057390d102dac1e6551769ba14f81f16ab9c69;hb=7af343f176b34839e17d03e5f2ea9dc45b56f6d2;hpb=3fd1252d032560af86c28d2dd55fa73b304e8435 diff --git a/plugins/filters/setup.php b/plugins/filters/setup.php index 19057390..782e1ac5 100644 --- a/plugins/filters/setup.php +++ b/plugins/filters/setup.php @@ -1,83 +1,66 @@ - * 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. - * - */ - // Set this to true if you have problems -- check the README file - // Note: This doesn't work all of the time (No idea why) - // Seems to be related to UW - global $UseSeparateImapConnection; - $UseSeparateImapConnection = false; +/** + * Message and Spam Filter Plugin - Setup + * + * @copyright © 1999-2007 The SquirrelMail Project Team + * @license http://opensource.org/licenses/gpl-license.php GNU Public License + * @version $Id$ + * @package plugins + * @subpackage filters + */ - // Set this to false if you do not want the user to be able to enable - // spam filters - global $AllowSpamFilters; - $AllowSpamFilters = true; +/** + * Init plugin + * @access private + */ +function squirrelmail_plugin_init_filters() { + global $squirrelmail_plugin_hooks; - // Set this to a string containing something unique to the line in the - // header you want me to find IPs to scan the databases with. For example, - // All the email coming IN from the internet to my site has a line in - // the header that looks like (all on one line): - // Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net - // [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam - // 0.2) with - // Since this line indicates the FIRST hop the email takes into my network, - // I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any - // case-sensitive string will do. You can set it to something found on - // every line in the header (like ' ') if you want to scan all IPs in - // the header (lots of false alarms here tho). + $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters_hook'; + $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters_hook'; + $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block_hook'; + $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; + $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder_hook'; + $squirrelmail_plugin_hooks['template_construct_login_webmail.tpl']['filters'] = 'start_filters_hook'; + $squirrelmail_plugin_hooks['folder_status']['filters'] = 'filters_folder_status'; +} - global $SpamFilters_YourHop; - $SpamFilters_YourHop = 'by firewall.persistence.com'; +/** + * Report spam folder as special mailbox + * @param string $mb variable used by hook + * @return string spam folder name + * @access private + */ +function filters_special_mailbox( $mb ) { + global $data_dir, $username; + return( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) ); +} - // A cache of IPs we've already checked or are known bad boys or good boys - // ie. $SpamFilters_DNScache["210.54.220.18"] = true; - // would tell filters to not even bother doing the DNS queries for that - // IP and any email coming from it are SPAM - false would mean that any - // email coming from it would NOT be SPAM - global $SpamFilters_DNScache; +/** + * Called by hook to Register option blocks + * @access private + */ +function filters_optpage_register_block_hook() { + include_once(SM_PATH . 'plugins/filters/filters.php'); + filters_optpage_register_block (); +} - require_once ('../plugins/filters/filters.php'); +/** + * Called by hook to Start Filtering + * @param mixed $args optional variable passed by hook + * @access private + */ +function start_filters_hook($args) { + include_once(SM_PATH . 'plugins/filters/filters.php'); + start_filters ($args); +} - function squirrelmail_plugin_init_filters() { - global $squirrelmail_plugin_hooks; - global $mailbox, $imap_stream, $imapConnection; - - $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters'; - if ($mailbox == 'INBOX') - $squirrelmail_plugin_hooks["right_main_after_header"]['filters'] = 'start_filters'; - $squirrelmail_plugin_hooks['options_register']['filters'] = 'squirrelmail_plugin_register'; - } - - function squirrelmail_plugin_register() { - global $optionpages; - - $optionpages[] = array( - 'name' => _("Message Filters"), - 'url' => '../plugins/filters/options.php', - 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."), - 'js' => false - ); - } -?> \ No newline at end of file +/** + * Called by hook to Update filters when Folders Change + * @access private + */ +function update_for_folder_hook($args) { + include_once(SM_PATH . 'plugins/filters/filters.php'); + update_for_folder ($args); +}