1: <?php
2: /**
3: * This class handles the search query for messages sent from a contact
4: * located in a user's addressbook.
5: *
6: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (GPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/gpl.
10: *
11: * @author Michael Slusarz <slusarz@horde.org>
12: * @category Horde
13: * @license http://www.horde.org/licenses/gpl GPL
14: * @package IMP
15: */
16: class IMP_Search_Element_Contacts extends IMP_Search_Element
17: {
18: /**
19: * Constructor.
20: *
21: * @param boolean $not If true, do a 'NOT' search.
22: */
23: public function __construct($not = false)
24: {
25: /* Data element: (integer) Do a NOT search? */
26: $this->_data = intval(!empty($not));
27: }
28:
29: /**
30: */
31: public function createQuery($mbox, $queryob)
32: {
33: $addrs = array();
34:
35: foreach (IMP_Compose::getAddressList('', true) as $val) {
36: $ob = new Horde_Imap_Client_Search_Query();
37: $ob->headerText('from', $val, $this->_data);
38: $addrs[] = $ob;
39: }
40:
41: $queryob->orSearch($addrs);
42:
43: return $queryob;
44: }
45:
46: /**
47: */
48: public function queryText()
49: {
50: return $this->_data
51: ? _("messages not from a personal contact")
52: : _("messages from a personal contact");
53: }
54:
55: }
56: