1: <?php
2: /**
3: * This class provides a data structure for storing a stored filter.
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_Filter extends IMP_Search_Query
16: {
17: /**
18: * Display this filter in the preferences screen?
19: *
20: * @var boolean
21: */
22: public $prefDisplay = true;
23:
24: /**
25: */
26: public function __get($name)
27: {
28: switch ($name) {
29: case 'querytext':
30: $text = array(_("Search"));
31:
32: foreach ($this->_criteria as $elt) {
33: $text[] = $elt->queryText();
34: if (!($elt instanceof IMP_Search_Element_Or)) {
35: $text[] = _("and");
36: }
37: }
38: array_pop($text);
39:
40: return implode(' ', $text);
41: }
42:
43: return parent::__get($name);
44: }
45:
46: /**
47: * Creates a query object from this filter.
48: *
49: * @param array $mboxes The list of mailboxes to apply the filter to.
50: * @param string $id The query ID to use.
51: *
52: * @return IMP_Search_Query A query object.
53: */
54: public function toQuery(array $mboxes, $id = null)
55: {
56: return new IMP_Search_Query(array(
57: 'add' => $this->_criteria,
58: 'id' => $id,
59: 'label' => $this->label,
60: 'mboxes' => $mboxes
61: ));
62: }
63:
64: }
65: