1: <?php
2: /**
3: * Copyright 2011-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 2011-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Search query for messages sent from a contact located in a user's
16: * addressbook.
17: *
18: * @author Michael Slusarz <slusarz@horde.org>
19: * @category Horde
20: * @copyright 2011-2014 Horde LLC
21: * @license http://www.horde.org/licenses/gpl GPL
22: * @package IMP
23: */
24: class IMP_Search_Element_Contacts extends IMP_Search_Element
25: {
26: /**
27: * Constructor.
28: *
29: * @param boolean $not If true, do a 'NOT' search.
30: */
31: public function __construct($not = false)
32: {
33: /* Data element: (integer) Do a NOT search? */
34: $this->_data = intval(!empty($not));
35: }
36:
37: /**
38: */
39: public function createQuery($mbox, $queryob)
40: {
41: $ajax = new IMP_Ajax_Imple_ContactAutoCompleter();
42: foreach ($ajax->getAddressList()->bare_addresses as $val) {
43: $ob = new Horde_Imap_Client_Search_Query();
44: $ob->headerText('from', $val, $this->_data);
45: $queryob->orSearch($ob);
46: }
47:
48: return $queryob;
49: }
50:
51: /**
52: */
53: public function queryText()
54: {
55: return $this->_data
56: ? _("messages not from a personal contact")
57: : _("messages from a personal contact");
58: }
59:
60: }
61: