1<?php 2/** 3 * Copyright 2010-2017 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-2017 Horde LLC 10 * @license http://www.horde.org/licenses/gpl GPL 11 * @package IMP 12 */ 13 14/** 15 * A data structure for storing a stored filter. 16 * 17 * @author Michael Slusarz <slusarz@horde.org> 18 * @category Horde 19 * @copyright 2010-2017 Horde LLC 20 * @license http://www.horde.org/licenses/gpl GPL 21 * @package IMP 22 */ 23class IMP_Search_Filter extends IMP_Search_Query 24{ 25 /** 26 * Display this filter in the preferences screen? 27 * 28 * @var boolean 29 */ 30 public $prefDisplay = true; 31 32 /** 33 */ 34 public function __get($name) 35 { 36 switch ($name) { 37 case 'querytext': 38 $text = array(); 39 40 foreach ($this->_criteria as $elt) { 41 $text[] = $elt->queryText(); 42 if (!($elt instanceof IMP_Search_Element_Or)) { 43 $text[] = _("and"); 44 } 45 } 46 array_pop($text); 47 48 return sprintf(_("Search %s"), implode(' ', $text)); 49 } 50 51 return parent::__get($name); 52 } 53 54 /** 55 * Creates a query object from this filter. 56 * 57 * @param array $mboxes The list of mailboxes to apply the filter to. 58 * @param string $id The query ID to use. 59 * 60 * @return IMP_Search_Query A query object. 61 */ 62 public function toQuery(array $mboxes, $id = null) 63 { 64 return new IMP_Search_Query(array( 65 'add' => $this->_criteria, 66 'id' => $id, 67 'label' => $this->label, 68 'mboxes' => $mboxes 69 )); 70 } 71 72} 73