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