From: Michael M Slusarz Date: Wed, 22 Sep 2010 06:08:00 +0000 (-0600) Subject: Request #8659: Add personal recipient message filter X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=13dcbf8f824f5aefc3f2add2e7642d5e8fbba1f4;p=horde.git Request #8659: Add personal recipient message filter --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 476031223..0f5d77316 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -408,7 +408,7 @@ $_prefs['filter'] = array( // 'disable' => false // )) // )) - 'value' => 'a:2:{i:0;C:22:"IMP_Search_Filter_Bulk":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}}' + 'value' => 'a:3:{i:0;C:22:"IMP_Search_Filter_Bulk":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}i:2;C:26:"IMP_Search_Filter_Personal":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}}' ); diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 0a31ee4ba..df693d31d 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Add personal recipient message filter (Request #8659). [mms] Add mailing list message filter (Request #8659). [mms] Add ability to define search criteria to be applied to any mailbox (Request #8659). diff --git a/imp/js/search.js b/imp/js/search.js index 3e4c9e7ef..19a148630 100644 --- a/imp/js/search.js +++ b/imp/js/search.js @@ -84,6 +84,10 @@ var ImpSearch = { this.insertOr(); break; + case 'IMP_Search_Element_Personal': + this.insertFilter('personal', crit); + break; + case 'IMP_Search_Element_Recipient': this.insertText('recip', crit.t, crit.n); break; diff --git a/imp/lib/Search/Element/Personal.php b/imp/lib/Search/Element/Personal.php new file mode 100644 index 000000000..62c6c9fc2 --- /dev/null +++ b/imp/lib/Search/Element/Personal.php @@ -0,0 +1,72 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +class IMP_Search_Element_Personal 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) + { + $and_ob = new Horde_Imap_Client_Search_Query(); + $identity = $GLOBALS['injector']->getInstance('IMP_Identity'); + + foreach ($identity->getAllIdentityAddresses() as $val) { + $ob = new Horde_Imap_Client_Search_Query(); + $ob->headerText('to', $val, $this->_data); + $and_ob->orSearch(array($ob)); + + $ob = new Horde_Imap_Client_Search_Query(); + $ob->headerText('cc', $val, $this->_data); + $and_ob->orSearch(array($ob)); + + $ob = new Horde_Imap_Client_Search_Query(); + $ob->headerText('bcc', $val, $this->_data); + $and_ob->orSearch(array($ob)); + } + + $queryob->andSearch(array($and_ob)); + + return $queryob; + } + + /** + * Return search query text representation. + * + * @return array The textual description of this search element. + */ + public function queryText() + { + return ($this->_data ? _("not") . ' ' : '') . _("Personal Messages"); + } + +} diff --git a/imp/lib/Search/Filter/Personal.php b/imp/lib/Search/Filter/Personal.php new file mode 100644 index 000000000..6549b9c5c --- /dev/null +++ b/imp/lib/Search/Filter/Personal.php @@ -0,0 +1,28 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +class IMP_Search_Filter_Personal extends IMP_Search_Filter_Builtin +{ + /** + * Initialization tasks. + */ + protected function _init() + { + $this->_id = 'filter_personal'; + $this->_label = _("Personal Messages"); + + $this->add(new IMP_Search_Element_Personal()); + } + +} diff --git a/imp/search.php b/imp/search.php index 663e2a67a..f153309cc 100644 --- a/imp/search.php +++ b/imp/search.php @@ -112,6 +112,10 @@ $filters = array( 'label' => _("Mailing List Messages"), 'type' => 'filter' ), + 'personal' => array( + 'label' => _("Personal Messages"), + 'type' => 'filter' + ), ); /* Define some constants. */ @@ -234,6 +238,12 @@ if ($vars->criteria_form) { ); break; + case 'personal': + $c_list[] = new IMP_Search_Element_Personal( + $val->n + ); + break; + case 'flag': /* Flag search. */ $formdata = $imp_flags->parseFormId($val->v);