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: * Flag/keyword search queries.
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_Flag extends IMP_Search_Element
24: {
25: /**
26: * Allow NOT search on this element?
27: *
28: * @var boolean
29: */
30: public $not = false;
31:
32: /**
33: * Constructor.
34: *
35: * @param string $name The flag or keyword name.
36: * @param boolean $set If true, search for messages that have the flag
37: * set. If false, search for messages that do not
38: * have the flag set.
39: */
40: public function __construct($name, $set = true)
41: {
42: /* Data element:
43: * f = (string) Flag/keyword name.
44: * s = (integer) Search for set flag? */
45: $this->_data = new stdClass;
46: $this->_data->f = $name;
47: $this->_data->s = intval(!empty($set));
48: }
49:
50: /**
51: */
52: public function createQuery($mbox, $queryob)
53: {
54: $queryob->flag($this->_data->f, $this->_data->s);
55:
56: return $queryob;
57: }
58:
59: /**
60: */
61: public function queryText()
62: {
63: $imp_flags = $GLOBALS['injector']->getInstance('IMP_Flags');
64:
65: return ($tmp = $imp_flags[$this->_data->f])
66: ? sprintf(_("flagged \"%s\""), $tmp->getLabel($this->_data->s))
67: : '';
68: }
69:
70: }
71: