From: Michael M Slusarz Date: Wed, 22 Sep 2010 05:42:49 +0000 (-0600) Subject: Request #8659: Add mailing list message filter X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=bdd30e2638f28b49be149056e1fffb50fcfb1199;p=horde.git Request #8659: Add mailing list message filter --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 512f8abf1..113e7f869 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -402,9 +402,13 @@ $_prefs['filter'] = array( // // Bulk filter, enabled by default // new IMP_Search_Filter_Bulk(array( // 'disable' => false + // )), + // // Mailing list filter, enabled by default + // new IMP_Search_Filter_Mailinglist(array( + // 'disable' => false // )) // )) - 'value' => 'a:1:{i:0;C:22:"IMP_Search_Filter_Bulk":88:{a:3:{s:1:"c";a:1:{i:0;C:23:"IMP_Search_Element_Bulk":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}}' + 'value' => 'a:2:{i:0;C:22:"IMP_Search_Filter_Bulk":88:{a:3:{s:1:"c";a:1:{i:0;C:23:"IMP_Search_Element_Bulk":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":95:{a:3:{s:1:"c";a:1:{i:0;C:30:"IMP_Search_Element_Mailinglist":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}}' ); diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 53c6ba861..0a31ee4ba 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Add mailing list message filter (Request #8659). [mms] Add ability to define search criteria to be applied to any mailbox (Request #8659). [mms] Use recipient search (To/Cc/Bcc) by default instead of To search. diff --git a/imp/js/search.js b/imp/js/search.js index f804b18d2..3e4c9e7ef 100644 --- a/imp/js/search.js +++ b/imp/js/search.js @@ -76,6 +76,10 @@ var ImpSearch = { } break; + case 'IMP_Search_Element_Mailinglist': + this.insertFilter('mailinglist', crit); + break; + case 'IMP_Search_Element_Or': this.insertOr(); break; diff --git a/imp/lib/Search/Element/Mailinglist.php b/imp/lib/Search/Element/Mailinglist.php new file mode 100644 index 000000000..a74c92ac4 --- /dev/null +++ b/imp/lib/Search/Element/Mailinglist.php @@ -0,0 +1,55 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +class IMP_Search_Element_Mailinglist extends IMP_Search_Element +{ + /** + * Constructor. + * + * @param boolean $not If true, do a 'NOT' search of $text. + */ + public function __construct($not = false) + { + /* Data element: (integer) Do a NOT search? */ + $this->_data = intval($not); + } + + /** + * Adds the current query item to the query object. + * + * @param Horde_Imap_Client_Search_Query The query object. + * + * @return Horde_Imap_Client_Search_Query The query object. + */ + public function createQuery($queryob) + { + $queryob->headerText('list-id', '', $this->_data); + + return $queryob; + } + + /** + * Return search query text representation. + * + * @return array The textual description of this search element. + */ + public function queryText() + { + return ($this->_data ? _("not") . ' ' : '') . _("Mailing List Message"); + } + +} diff --git a/imp/lib/Search/Filter/Mailinglist.php b/imp/lib/Search/Filter/Mailinglist.php new file mode 100644 index 000000000..9ebde46d9 --- /dev/null +++ b/imp/lib/Search/Filter/Mailinglist.php @@ -0,0 +1,69 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +class IMP_Search_Filter_Mailinglist extends IMP_Search_Filter +{ + /** + * Can this query be edited? + * + * @var boolean + */ + protected $_canEdit = false; + + /** + * List of serialize entries not to save. + * + * @var array + */ + protected $_nosave = array('i', 'l'); + + /** + * Constructor. + * + * The 'add', 'id', 'label', and 'mboxes' parameters are ignored. + * + * @see parent::__construct() + */ + public function __construct(array $opts = array()) + { + $this->enabled = empty($opts['disable']); + + $this->add(new IMP_Search_Element_Mailinglist()); + + $this->_init(); + } + + /** + * Initialization tasks. + */ + protected function _init() + { + $this->_id = 'filter_mlist'; + $this->_label = _("Mailing List Messages"); + } + + /** + * Unserialization. + * + * @param string $data Serialized data. + * + * @throws Exception + */ + public function unserialize($data) + { + parent::unserialize($data); + $this->_init(); + } + +} diff --git a/imp/search.php b/imp/search.php index 36183f8c7..663e2a67a 100644 --- a/imp/search.php +++ b/imp/search.php @@ -108,6 +108,10 @@ $filters = array( 'label' => _("Bulk Messages"), 'type' => 'filter' ), + 'mailinglist' => array( + 'label' => _("Mailing List Messages"), + 'type' => 'filter' + ), ); /* Define some constants. */ @@ -224,6 +228,12 @@ if ($vars->criteria_form) { ); break; + case 'mailinglist': + $c_list[] = new IMP_Search_Element_Mailinglist( + $val->n + ); + break; + case 'flag': /* Flag search. */ $formdata = $imp_flags->parseFormId($val->v);