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