From 41d697490fcd624fa8f94f058fb7a48473c17ca9 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 9 Feb 2010 16:54:13 -0700 Subject: [PATCH] Add IMP_Folder binder class. Cache ID for folder list must include server key - or else logging into different servers will give server list from last server. --- imp/lib/Application.php | 1 + imp/lib/Folder.php | 12 +++++++----- imp/lib/Injector/Binder/Folder.php | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 imp/lib/Injector/Binder/Folder.php diff --git a/imp/lib/Application.php b/imp/lib/Application.php index b982952cb..0db7ae76a 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -92,6 +92,7 @@ class IMP_Application extends Horde_Registry_Application */ protected function _init() { + $GLOBALS['injector']->addBinder('IMP_Folder', new IMP_Injector_Binder_Folder()); $GLOBALS['injector']->addBinder('IMP_Imap_Tree', new IMP_Injector_Binder_Imaptree()); // Initialize global $imp_imap object. diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index 8d0836197..61aefdc78 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -34,12 +34,13 @@ class IMP_Folder /** * Constructor. + * + * @param string $cacheid The cache ID to use, if folder list caching is + * enabled. */ - public function __construct() + public function __construct($cacheid = null) { - if (!empty($GLOBALS['conf']['server']['cache_folders'])) { - $this->_cacheid = 'imp_folder_cache|' . Horde_Auth::getAuth(); - } + $this->_cacheid = $cacheid; } /** @@ -136,7 +137,8 @@ class IMP_Folder */ public function clearFlistCache() { - if (!is_null($this->_cacheid) && ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) { + if (!is_null($this->_cacheid) && + ($cache = $GLOBALS['injector']->getInstance('Horde_Cache'))) { $cache->expire($this->_cacheid); } $this->_listCache = array(); diff --git a/imp/lib/Injector/Binder/Folder.php b/imp/lib/Injector/Binder/Folder.php new file mode 100644 index 000000000..6a924ba04 --- /dev/null +++ b/imp/lib/Injector/Binder/Folder.php @@ -0,0 +1,33 @@ + + * @package IMP + */ +class IMP_Injector_Binder_Folder implements Horde_Injector_Binder +{ + /** + */ + public function create(Horde_Injector $injector) + { + $cacheid = empty($GLOBALS['conf']['server']['cache_folders']) + ? null + : 'imp_folder_cache|' . Horde_Auth::getAuth() . '|' . $_SESSION['imp']['server_key']; + + return new IMP_Folder($cacheid); + } + + /** + */ + public function equals(Horde_Injector_Binder $binder) + { + return false; + } + +} -- 2.11.0