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: * Size-related 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_Size 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 integer $size The size (in bytes).
36: * @param boolean $larger Search for messages larger than $size?
37: */
38: public function __construct($size, $larger = false)
39: {
40: /* Data element:
41: * l = (integer) Larger if non-zero, smaller if zero.
42: * s = (integer) Size (in bytes). */
43: $this->_data = new stdClass;
44: $this->_data->s = intval($size);
45: $this->_data->l = intval(!empty($larger));
46: }
47:
48: /**
49: */
50: public function createQuery($mbox, $queryob)
51: {
52: $queryob->size($this->_data->s, $this->_data->l);
53:
54: return $queryob;
55: }
56:
57: /**
58: */
59: public function queryText()
60: {
61: $label = $this->_data->l
62: ? _("Size - Greater Than (KB)")
63: : _("Size - Less Than (KB)");
64:
65: return $label . ' ' . ($this->_data->s / 1024);
66: }
67:
68: }
69: