From: Michael M Slusarz Date: Mon, 6 Sep 2010 23:33:52 +0000 (-0600) Subject: Encapsulate all search data within IMP_Search X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7980771d0684f78a9f996512a6c38b6df3f3491b;p=horde.git Encapsulate all search data within IMP_Search --- diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 33c268646..61e05f793 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -557,7 +557,7 @@ class IMP_Application extends Horde_Registry_Application { $this->init(); $this->mailboxesChanged(); - $GLOBALS['injector']->getInstance('IMP_Search')->initialize(true); + $GLOBALS['injector']->getInstance('IMP_Search')->init(true); } /* Helper methods. */ diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index 1eb2bbcb0..84c7e1558 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -186,7 +186,7 @@ class IMP_Auth * 'notepadavail' - (boolean) Is listing of notepads available? * 'protocol' - (string) Either 'imap' or 'pop'. * 'rteavail' - (boolean) Is the HTML editor available? - * 'search' - (array) Settings used by the IMP_Search library. + * 'search' - (string) The serialized IMP_Search object. * 'server_key' - (string) Server used to login. * 'smime' - (array) Settings related to the S/MIME viewer. * 'smtp' - (array) SMTP options ('host' and 'port') @@ -500,8 +500,10 @@ class IMP_Auth ); } - /* Set up search information for the session. */ - $GLOBALS['injector']->getInstance('IMP_Search')->initialize(); + /* Set up search information for the session. Need to manually do + * first init() here since there is a cyclic IMP_Imap_Tree dependency + * otherwise. */ + $GLOBALS['injector']->getInstance('IMP_Search')->init(); /* If the user wants to run filters on login, make sure they get run. */ diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index 96c57808c..bd127554f 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -79,7 +79,7 @@ class IMP_Folder protected function _onDelete($deleted) { /* Recreate Virtual Folders. */ - $GLOBALS['injector']->getInstance('IMP_Search')->initialize(true); + $GLOBALS['injector']->getInstance('IMP_Search')->init(true); /* Clear the folder from the sort prefs. */ foreach ($deleted as $val) { @@ -164,7 +164,7 @@ class IMP_Folder $GLOBALS['injector']->getInstance('IMP_Imap_Tree')->insert($folder); /* Recreate Virtual Folders. */ - $GLOBALS['injector']->getInstance('IMP_Search')->initialize(true); + $GLOBALS['injector']->getInstance('IMP_Search')->init(true); return true; } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 96b207442..2ea5f4bec 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -120,9 +120,9 @@ class IMP */ static public function getLabel($mbox) { - $label = IMP_Search::isSearchMbox($mbox) - ? $GLOBALS['injector']->getInstance('IMP_Search')->getLabel($mbox) - : self::displayFolder($mbox); + if (!($label = $GLOBALS['injector']->getInstance('IMP_Search')->getLabel($mbox))) { + $label = self::displayFolder($mbox); + } try { return Horde::callHook('mbox_label', array($mbox, $label), 'imp'); @@ -737,7 +737,7 @@ class IMP if (is_null($delhide) || $force) { if ($GLOBALS['prefs']->getValue('use_vtrash')) { - $delhide = !$GLOBALS['injector']->getInstance('IMP_Search')->isVTrashFolder(); + $delhide = !$GLOBALS['injector']->getInstance('IMP_Search')->isVTrashFolder($mbox); } else { $sortpref = self::getSort(); $delhide = ($GLOBALS['prefs']->getValue('delhide') && diff --git a/imp/lib/Injector/Binder/Search.php b/imp/lib/Injector/Binder/Search.php index cf9f09484..2172ad072 100644 --- a/imp/lib/Injector/Binder/Search.php +++ b/imp/lib/Injector/Binder/Search.php @@ -15,12 +15,50 @@ class IMP_Injector_Binder_Search implements Horde_Injector_Binder { /** + * Injector. + * + * @var Horde_Injector + */ + private $_injector; + + /** + * If an IMP_Search object is currently stored in the session, re-create + * that object. Else, create a new instance. + * + * @param Horde_Injecton $injector Parent injector. */ public function create(Horde_Injector $injector) { - return new IMP_Search(array( - 'id' => (isset($_SESSION['imp']) && IMP_Search::isSearchMbox(IMP::$mailbox)) ? IMP::$mailbox : null - )); + $this->_injector = $injector; + + $instance = null; + + if (!empty($_SESSION['imp']['search'])) { + try { + $instance = @unserialize($_SESSION['imp']['search']); + } catch (Exception $e) { + Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG'); + } + } + + if (is_null($instance)) { + $instance = new IMP_Search(); + } + + register_shutdown_function(array($this, 'shutdown'), $instance); + + return $instance; + } + + /** + * Store serialized version of object in the current session. + */ + public function shutdown($instance) + { + /* Only need to store the object if the object has changed. */ + if ($instance->changed) { + $_SESSION['imp']['search'] = serialize($instance); + } } /** diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 63fb71d04..2028963b8 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -257,7 +257,7 @@ class IMP_Message if ($this->_usepop || !empty($options['nuke']) || ($use_trash && ($mbox == $trash)) || - ($use_vtrash && ($GLOBALS['injector']->getInstance('IMP_Search')->isVTrashFolder()))) { + ($use_vtrash && ($GLOBALS['injector']->getInstance('IMP_Search')->isVTrashFolder($mbox)))) { /* Purge messages immediately. */ $expunge_now = true; } else { diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index a7a6297b4..310de5c17 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -536,7 +536,7 @@ class IMP_Prefs_Ui $ui->suppress = array_diff($ui->suppress, array('trashselect', 'empty_trash_menu')); } if ($prefs->isDirty('use_vtrash')) { - $GLOBALS['injector']->getInstance('IMP_Search')->initialize(true); + $GLOBALS['injector']->getInstance('IMP_Search')->init(true); } break; @@ -556,7 +556,7 @@ class IMP_Prefs_Ui case 'server': if ($prefs->isDirty('use_vinbox')) { - $GLOBALS['injector']->getInstance('IMP_Search')->initialize(true); + $GLOBALS['injector']->getInstance('IMP_Search')->init(true); } if ($prefs->isDirty('subscribe')) { diff --git a/imp/lib/Search.php b/imp/lib/Search.php index 0d01b8085..b759b249e 100644 --- a/imp/lib/Search.php +++ b/imp/lib/Search.php @@ -3,54 +3,6 @@ * The IMP_Search:: class contains all code related to mailbox searching * in IMP. * - * The class uses the $_SESSION['imp']['search'] variable to store information - * across page accesses. The format of that entry is as follows: - * - * $_SESSION['imp']['search'] = array( - * 'id_1' => array( - * 'c' => (array) List of search criteria (the IMP-specific data - * structure that allows recreation of the search query on the - * search page). For virtual folders, this data is stored in - * the preferences, - * 'f' => (array) List of folders to search, - * 'l' => (string) Description (label) of search, - * 'q' => (Horde_Imap_Client_Search_Query) [serialized], - * 'v' => (boolean) True if this is a Virtual Folder - * ), - * .... - * ); - * - * The format of the 'c' (search criteria) array is as follows: - * array( - * stdClass object { - * 't' => (string) 'Type' - The criteria type - * Values: Keys from self::searchFields(), 'flag', and 'or'. - * 'v' => (mixed) 'Value' - The data used to build the search - * 'header' - (string) The value to search for in the header - * 'customhdr' - (stdClass object) Contains 2 elements: - * 'h' - (string) The header name - * 's' - (string) The search string - * 'body' - (string) The value to search for in the body - * 'text' - (string) The value to search for in the entire - * message - * 'date' - (stdClass object) Contains 3 elements: - * 'y' - (integer) The search year - * 'm' - (integer) The search month (is 1 less than - * the actual month) - * 'd' - (integer) The search day - * 'within' - (stdClass object) Contains 2 elements: - * 'l' - (string) The length of time. Either 'y' - * (years), 'm' (months), or 'd' (days) - * 'v' - (integer) The length of time - * 'size' - (integer) The search size in bytes - * 'flag' - (string) The flag to search for - * 'n' => (boolean) 'Not' - Should we do a not search? - * Only used for the following types: header, customhdr, body, - * text - * }, - * ... - * ) - * * Copyright 2002-2010 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you @@ -61,7 +13,7 @@ * @license http://www.fsf.org/copyleft/gpl.html GPL * @package IMP */ -class IMP_Search +class IMP_Search implements Serializable { /* The mailbox search prefix. */ const MBOX_PREFIX = "impsearch\0"; @@ -77,11 +29,11 @@ class IMP_Search const NO_BASIC_SEARCH = 4; /** - * The ID of the current search query in use. + * Has the object data changed? * - * @var string + * @var boolean */ - protected $_id = null; + public $changed = false; /** * Save Virtual Folder information when adding entries? @@ -98,18 +50,79 @@ class IMP_Search protected $_cache = array(); /** - * Constructor. + * Search queries. * - * @param array $params Available parameters: + * Format: *
-     * 'id' - (string) The ID of the search query in use.
+     * 'id' => array(
+     *     'c' => (array) List of search criteria (the IMP-specific data
+     *            structure that allows recreation of the search query on the
+     *            search page). For virtual folders, this data is stored in
+     *            the preferences,
+     *     'f' => (array) List of folders to search,
+     *     'l' => (string) Description (label) of search,
+     *     'q' => (Horde_Imap_Client_Search_Query) [serialized],
+     *     'v' => (boolean) True if this is a Virtual Folder
+     * )
      * 
+ * + * The object properties for the 'c' (search criteria) object: + *
+     * 't' - (string) 'Type' - The criteria type
+     *       Values: Keys from self::searchFields(), 'flag', and 'or'.
+     * 'v' - (mixed) 'Value' - The data used to build the search
+     *       'header' - (string) The value to search for in the header
+     *       'customhdr' - (object) Contains 2 elements:
+     *                     'h' - (string) The header name
+     *                     's' - (string) The search string
+     *       'body' - (string) The value to search for in the body
+     *       'text' - (string) The value to search for in the entire
+     *                message
+     *       'date' - (object) Contains 3 elements:
+     *                'y' - (integer) The search year
+     *                'm' - (integer) The search month (is 1 less than
+     *                      the actual month)
+     *                'd' - (integer) The search day
+     *       'within' - (object) Contains 2 elements:
+     *                  'l' - (string) The length of time. Either 'y'
+     *                        (years), 'm' (months), or 'd' (days)
+     *                  'v' - (integer) The length of time
+     *       'size' - (integer) The search size in bytes
+     *       'flag' - (string) The flag to search for
+     * 'n' - (boolean) 'Not' - Should we do a not search?
+     *       Only used for the following types: header, customhdr, body, text
+     * 
+ * + * @var array */ - public function __construct($params = array()) + protected $_search = array(); + + /** + * Serialize. + * + * @return string Serialized representation of this object. + */ + public function serialize() { - if (!empty($params['id'])) { - $this->_id = $this->_strip($params['id']); + return serialize($this->_search); + } + + /** + * Unserialize. + * + * @param string $data Serialized data. + * + * @throws Exception + */ + public function unserialize($data) + { + $data = @unserialize($data); + if (!is_array($data)) { + throw new Exception('Cache version change'); } + + $this->_search = $data; + $this->changed = true; } /** @@ -117,7 +130,7 @@ class IMP_Search * * @param boolean $no_vf Don't readd the Virtual Folders. */ - public function initialize($no_vf = false) + public function init($no_vf = false) { if (!$no_vf) { $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree'); @@ -126,10 +139,12 @@ class IMP_Search !$this->isEditableVFolder($key)) { $imaptree->insertVFolders(array($key => $val['l'])); unset($val['c']); - $_SESSION['imp']['search'][$key] = $val; + $this->_search[$key] = $val; + $this->changed = true; } } } + $this->createVINBOXFolder(); $this->createVTrashFolder(); } @@ -245,25 +260,23 @@ class IMP_Search * * @param object $ob An optional search query to add (via 'AND') to the * active search (Horde_Imap_Client_Search_Query). - * @param string $id The search query id to use (by default, will use the - * current ID set in the object). + * @param string $id The search query id. * * @return IMP_Indices An indices object. * @throws Horde_Imap_Client_Exception */ - public function runSearch($ob, $id = null) + public function runSearch($ob, $id) { $id = $this->_strip($id); $mbox = ''; $sorted = new IMP_Indices(); - if (empty($_SESSION['imp']['search'][$id])) { + if (empty($this->_search[$id])) { return $sorted; } - $search = &$_SESSION['imp']['search'][$id]; /* Prepare the search query. */ - $query = unserialize($search['q']); + $query = unserialize($this->_search[$id]['q']); if (!empty($ob)) { $query->andSearch(array($ob)); } @@ -274,7 +287,7 @@ class IMP_Search $sortpref['by'] = $GLOBALS['prefs']->getValue('sortdate'); } - foreach ($search['f'] as $val) { + foreach ($this->_search[$id]['f'] as $val) { $results = $this->imapSearch($val, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by']))); $sorted->add($val, $results['sort']); } @@ -362,7 +375,7 @@ class IMP_Search * @param array $folders The list of folders to search. * @param array $criteria The search criteria array. * @param string $label The label to use for the search results. - * @param string $id The query id to use (or else one is + * @param string $id The query id (otherwise, one is * automatically generated). * * @return string Returns the search query id. @@ -374,13 +387,14 @@ class IMP_Search ? strval(new Horde_Support_Randomid()) : $this->_strip($id); - $_SESSION['imp']['search'][$id] = array( + $this->_search[$id] = array( 'c' => $criteria, 'f' => $folders, 'l' => $label, 'q' => serialize($query), 'v' => false ); + $this->changed = true; return $id; } @@ -388,17 +402,17 @@ class IMP_Search /** * Deletes an IMAP search query. * - * @param string $id The search query id to use (by default, will - * use the current ID set in the object). + * @param string $id The search query id. * @param boolean $no_delete Don't delete the entry in the tree object. * * @return string Returns the search query id. */ - public function deleteSearchQuery($id = null, $no_delete = false) + public function deleteSearchQuery($id, $no_delete = false) { $id = $this->_strip($id); $is_vfolder = $this->isVFolder($id); - unset($_SESSION['imp']['search'][$id]); + unset($this->_search[$id]); + $this->changed = true; if ($is_vfolder) { $vfolders = $this->_getVFolderList(); @@ -414,16 +428,15 @@ class IMP_Search /** * Retrieves the previously stored search criteria information. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return array The array necessary to rebuild the search UI page. */ - public function getCriteria($id = null) + public function getCriteria($id) { $id = $this->_strip($id); - if (isset($_SESSION['imp']['search'][$id]['c'])) { - return $_SESSION['imp']['search'][$id]['c']; + if (isset($this->_search[$id]['c'])) { + return $this->_search[$id]['c']; } if ($this->isVFolder($id)) { @@ -437,16 +450,15 @@ class IMP_Search /** * Generates the label to use for search results. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return string The search results label. */ - public function getLabel($id = null) + public function getLabel($id) { $id = $this->_strip($id); - return isset($_SESSION['imp']['search'][$id]['l']) - ? $_SESSION['imp']['search'][$id]['l'] + return isset($this->_search[$id]['l']) + ? $this->_search[$id]['l'] : ''; } @@ -499,7 +511,8 @@ class IMP_Search public function addVFolder($query, $folders, $search, $label, $id = null) { $id = $this->createSearchQuery($query, $folders, $search, $label, $id); - $_SESSION['imp']['search'][$id]['v'] = true; + $this->_search[$id]['v'] = true; + $this->changed = true; if ($this->_saveVFolder) { $vfolders = $this->_getVFolderList(); @@ -547,17 +560,14 @@ class IMP_Search /** * Determines whether a virtual folder ID is the Virtual Trash Folder. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * - * @return boolean True if the virutal folder ID is the Virtual Trash - * folder. + * @return boolean True if the ID is the Virtual Trash folder. */ - public function isVTrashFolder($id = null) + public function isVTrashFolder($id) { - $id = $this->_strip($id); $vtrash_id = $GLOBALS['prefs']->getValue('vtrash_id'); - return (!empty($vtrash_id) && ($id == $vtrash_id)); + return (!empty($vtrash_id) && ($this->_strip($id) == $vtrash_id)); } /** @@ -596,29 +606,25 @@ class IMP_Search /** * Determines whether a virtual folder ID is the Virtual INBOX Folder. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * - * @return boolean True if the virutal folder ID is the Virtual INBOX - * folder. + * @return boolean True if the ID is the Virtual INBOX folder. */ - public function isVINBOXFolder($id = null) + public function isVINBOXFolder($id) { - $id = $this->_strip($id); $vinbox_id = $GLOBALS['prefs']->getValue('vinbox_id'); - return (!empty($vinbox_id) && ($id == $vinbox_id)); + return (!empty($vinbox_id) && ($this->_strip($id) == $vinbox_id)); } /** * Is a mailbox an editable Virtual Folder? * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * - * @return boolean True if the current folder is both a virtual folder - * and can be edited. + * @return boolean True if the mailbox is both a virtual folder and can + * be edited. */ - public function isEditableVFolder($id = null) + public function isEditableVFolder($id) { $id = $this->_strip($id); return ($this->isVFolder($id) && @@ -643,7 +649,7 @@ class IMP_Search { $folders = array(); - if (empty($_SESSION['imp']['search'])) { + if (empty($this->_search)) { return $folders; } @@ -651,7 +657,7 @@ class IMP_Search $mask = self::LIST_SEARCH | self::LIST_VFOLDER; } - foreach ($_SESSION['imp']['search'] as $key => $val) { + foreach ($this->_search as $key => $val) { if ((($mask & self::LIST_VFOLDER) && !empty($val['v'])) || (($mask & self::LIST_SEARCH) && empty($val['v'])) && (!($mask & self::NO_BASIC_SEARCH) || @@ -673,12 +679,11 @@ class IMP_Search /** * Get the list of searchable folders for the given search query. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return array The list of searchable folders. */ - public function getSearchFolders($id = null) + public function getSearchFolders($id) { $id = $this->_strip($id); return isset($_SESSION['imp']['search'][$id]['f']) @@ -689,19 +694,18 @@ class IMP_Search /** * Return search query text representation for a given search ID. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return array The textual description of the search. */ - public function searchQueryText($id = null) + public function searchQueryText($id) { $id = $this->_strip($id); - if (empty($_SESSION['imp']['search'][$id])) { + if (empty($this->_search[$id])) { return ''; } elseif ($this->isVINBOXFolder($id) || $this->isVTrashFolder($id)) { - return $_SESSION['imp']['search'][$id]['l']; + return $this->_search[$id]['l']; } $flagfields = $this->flagFields(); @@ -759,12 +763,11 @@ class IMP_Search /** * Returns a link to edit a given search query. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return Horde_Url The URL to the search page. */ - public function editUrl($id = null) + public function editUrl($id) { return Horde::url('search.php')->add(array('edit_query' => $this->createSearchID($this->_strip($id)))); } @@ -772,12 +775,11 @@ class IMP_Search /** * Returns a link to delete a given search query. * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return Horde_Url The URL to allow deletion of the search query. */ - public function deleteUrl($id = null) + public function deleteUrl($id) { return Horde::url('folders.php')->add(array( 'actionID' => 'delete_search_query', @@ -793,7 +795,7 @@ class IMP_Search * * @return boolean Whether the given mailbox name is a search mailbox. */ - static public function isSearchMbox($id) + public function isSearchMbox($id) { return (strpos($id, self::MBOX_PREFIX) === 0); } @@ -801,28 +803,13 @@ class IMP_Search /** * Is the given mailbox a virtual folder? * - * @param string $id The search query id to use (by default, will use - * the current ID set in the object). + * @param string $id The search query id. * * @return boolean Whether the given mailbox name is a virtual folder. */ - public function isVFolder($id = null) - { - $id = $this->_strip($id); - return !empty($_SESSION['imp']['search'][$id]['v']); - } - - /** - * Get the ID for the search mailbox, if we are currently in a search - * mailbox. - * - * @return mixed The search ID if in a mailbox, else false. - */ - public function searchMboxID() + public function isVFolder($id) { - return is_null($this->_id) - ? false - : $this->_id; + return !empty($this->_search[$this->_strip($id)]['v']); } /** @@ -835,10 +822,6 @@ class IMP_Search */ protected function _strip($id) { - if (is_null($id)) { - return $this->_id; - } - return $this->isSearchMbox($id) ? substr($id, strlen(self::MBOX_PREFIX)) : $id; diff --git a/imp/lib/Tree/Flist.php b/imp/lib/Tree/Flist.php index c454b46a9..1a65235a2 100644 --- a/imp/lib/Tree/Flist.php +++ b/imp/lib/Tree/Flist.php @@ -103,11 +103,10 @@ class IMP_Tree_Flist extends Horde_Tree_Select $vfolders = $imp_search->listQueries(IMP_Search::LIST_VFOLDER); if (!empty($vfolders)) { $vfolder_list = array(); - $vfolder_sel = $imp_search->searchMboxID(); foreach ($vfolders as $id => $val) { $vfolder_list[] = array( 'l' => $injector->getInstance('Horde_Text_Filter')->filter($val, 'space2html', array('encode' => true)), - 'sel' => ($vfolder_sel == $id), + 'sel' => (IMP::$mailbox == $id), 'v' => IMP::formMbox($imp_search->createSearchID($id), true) ); } diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index 2e72dd176..4a45c4c13 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -215,7 +215,7 @@ $search_mbox = $imp_search->isSearchMbox(IMP::$mailbox); /* Determine if we are going to show the Purge Deleted link. */ if (!$readonly && !$prefs->getValue('use_trash') && - !$imp_search->isVINBOXFolder()) { + !$imp_search->isVINBOXFolder(IMP::$mailbox)) { $menu[] = array(_("Purge Deleted"), $mailbox->copy()->add('a', 'e')); } @@ -247,7 +247,7 @@ if (!$search_mbox && IMP::threadSortAvailable($mailbox)) { /* Add search link. */ if ($_SESSION['imp']['protocol'] == 'imap') { if ($search_mbox) { - $orig_mbox = reset($imp_search->getSearchFolders()); + $orig_mbox = reset($imp_search->getSearchFolders(IMP::$mailbox)); $menu[] = array(sprintf(_("New Search in %s"), IMP::getLabel($orig_mbox)), IMP::generateIMPUrl('mailbox-mimp.php', $orig_mbox)->add('a', 's')); } else { $menu[] = array(_("Search"), $mailbox_url->copy()->add('a', 's')); diff --git a/imp/mailbox.php b/imp/mailbox.php index 5a346cb39..07041f781 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -50,7 +50,7 @@ try { $imp_search = $injector->getInstance('IMP_Search'); $search_mbox = $imp_search->isSearchMbox(IMP::$mailbox); $vars = Horde_Variables::getDefaultVariables(); -$vfolder = $imp_search->isVFolder(); +$vfolder = $imp_search->isVFolder(IMP::$mailbox); /* There is a chance that this page is loaded directly via message.php. If so, * don't re-include config files, and the following variables will already be @@ -229,7 +229,7 @@ $sortpref = IMP::getSort(IMP::$mailbox); /* Determine if we are going to show the Hide/Purge Deleted Message links. */ if (!$prefs->getValue('use_trash') && - !$imp_search->isVINBOXFolder()) { + !$imp_search->isVINBOXFolder(IMP::$mailbox)) { $showdelete = array('hide' => ($sortpref['by'] != Horde_Imap_Client::SORT_THREAD), 'purge' => true); } else { $showdelete = array('hide' => false, 'purge' => false); @@ -309,7 +309,7 @@ if (!$preview_tooltip) { } $unread = $imp_mailbox->unseenMessages(Horde_Imap_Client::SORT_RESULTS_COUNT); -$vtrash = $imp_search->isVTrashFolder() +$vtrash = $imp_search->isVTrashFolder(IMP::$mailbox) ? $imp_search->createSearchID($search_mbox) : null; @@ -336,8 +336,8 @@ if ($unread) { } if ($vfolder || - ($search_mbox && ($imp_search->searchMboxID() != IMP_Search::BASIC_SEARCH))) { - $query_text = wordwrap($imp_search->searchQueryText($imp_search->searchMboxID())); + ($search_mbox && (IMP::$mailbox != IMP_Search::BASIC_SEARCH))) { + $query_text = wordwrap($imp_search->searchQueryText(IMP::$mailbox)); if ($vfolder) { $pagetitle .= ' [' . Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . _("Virtual Folder") . ']'; $title .= ' [' . _("Virtual Folder") . ']'; @@ -400,13 +400,13 @@ if ($_SESSION['imp']['protocol'] != 'pop') { $hdr_template->set('empty_img', Horde::img('empty_spam.png', _("Empty folder"))); } } else { - if ($imp_search->isEditableVFolder()) { + if ($imp_search->isEditableVFolder(IMP::$mailbox)) { $edit_search = _("Edit Virtual Folder"); - $hdr_template->set('delete_vfolder_url', $imp_search->deleteUrl()); + $hdr_template->set('delete_vfolder_url', $imp_search->deleteUrl(IMP::$mailbox)); $hdr_template->set('delete_vfolder_img', Horde::img('delete.png', _("Delete Virtual Folder"))); } elseif ($search_mbox && !isset($query_text)) { /* Mini search results. */ - $search_mailbox = reset($imp_search->getSearchFolders()); + $search_mailbox = reset($imp_search->getSearchFolders(IMP::$mailbox)); $hdr_template->set('search_url', Horde::url('search-basic.php')->add('search_mailbox', $search_mailbox)); $hdr_template->set('searchclose', IMP::generateIMPUrl('mailbox.php', $search_mailbox)); } elseif (!$vfolder) { @@ -414,7 +414,7 @@ if ($_SESSION['imp']['protocol'] != 'pop') { } if (isset($edit_search)) { - $hdr_template->set('edit_search_url', $imp_search->editUrl()); + $hdr_template->set('edit_search_url', $imp_search->editUrl(IMP::$mailbox)); $hdr_template->set('edit_search_title', $edit_search); $hdr_template->set('edit_search_img', Horde::img('edit.png', $edit_search)); }