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: * Recipient (To/Cc/Bcc) search query.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2010-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Search_Element_Recipient extends IMP_Search_Element
24: {
25: /**
26: * Constructor.
27: *
28: * @param string $text The search text.
29: * @param boolean $not If true, do a 'NOT' search of $text.
30: */
31: public function __construct($text, $not = false)
32: {
33: /* Data element:
34: * n = (integer) Do a NOT search?
35: * t = (string) The search text. */
36: $this->_data = new stdClass;
37: $this->_data->n = intval(!empty($not));
38: $this->_data->t = $text;
39: }
40:
41: /**
42: */
43: public function createQuery($mbox, $queryob)
44: {
45: $search_ob = new Horde_Imap_Client_Search_Query();
46: $and_ob = clone $search_ob;
47:
48: $ob = clone $search_ob;
49: $ob->headerText('to', $this->_data->t, $this->_data->n);
50: $and_ob->orSearch($ob);
51:
52: $ob = clone $search_ob;
53: $ob->headerText('cc', $this->_data->t, $this->_data->n);
54: $and_ob->orSearch($ob);
55:
56: $ob = clone $search_ob;
57: $ob->headerText('bcc', $this->_data->t, $this->_data->n);
58: $and_ob->orSearch($ob);
59:
60: $queryob->andSearch($and_ob);
61:
62: return $queryob;
63: }
64:
65: /**
66: */
67: public function queryText()
68: {
69: return sprintf(_("Recipients (To/Cc/Bcc) for '%s'"), ($this->_data->n ? _("not") . ' ' : '') . $this->_data->t);
70: }
71:
72: }
73: