1: <?php
2: /**
3: * Copyright 2010-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2010-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Personal recipient search query.
16: *
17: * This query matches if one of the e-mails defined in the identities
18: * matches the To/Cc/Bcc header of an email.
19: *
20: * @author Michael Slusarz <slusarz@horde.org>
21: * @category Horde
22: * @copyright 2010-2014 Horde LLC
23: * @license http://www.horde.org/licenses/gpl GPL
24: * @package IMP
25: */
26: class IMP_Search_Element_Personal extends IMP_Search_Element
27: {
28: /**
29: * Constructor.
30: *
31: * @param boolean $not If true, do a 'NOT' search of $text.
32: */
33: public function __construct($not = false)
34: {
35: /* Data element: (integer) Do a NOT search? */
36: $this->_data = intval(!empty($not));
37: }
38:
39: /**
40: */
41: public function createQuery($mbox, $queryob)
42: {
43: $search_ob = new Horde_Imap_Client_Search_Query();
44: $and_ob = clone $search_ob;
45: $identity = $GLOBALS['injector']->getInstance('IMP_Identity');
46:
47: foreach ($identity->getAllIdentityAddresses()->bare_addresses as $val) {
48: $ob = clone $search_ob;
49: $ob->headerText('to', $val, $this->_data);
50: $and_ob->orSearch($ob);
51:
52: $ob = clone $search_ob;
53: $ob->headerText('cc', $val, $this->_data);
54: $and_ob->orSearch($ob);
55:
56: $ob = clone $search_ob;
57: $ob->headerText('bcc', $val, $this->_data);
58: $and_ob->orSearch($ob);
59: }
60:
61: $queryob->andSearch($and_ob);
62:
63: return $queryob;
64: }
65:
66: /**
67: */
68: public function queryText()
69: {
70: return ($this->_data ? _("not") . ' ' : '') . _("Personal Messages");
71: }
72:
73: }
74: