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