Add IMP_Folder binder class.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Feb 2010 23:54:13 +0000 (16:54 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 10 Feb 2010 06:10:42 +0000 (23:10 -0700)
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
imp/lib/Folder.php
imp/lib/Injector/Binder/Folder.php [new file with mode: 0644]

index b982952..0db7ae7 100644 (file)
@@ -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.
index 8d08361..61aefdc 100644 (file)
@@ -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 (file)
index 0000000..6a924ba
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Binder for IMP_Folder::.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @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;
+    }
+
+}