Move imap_ob storage to an array
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Nov 2009 21:08:07 +0000 (14:08 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 3 Dec 2009 21:53:39 +0000 (14:53 -0700)
imp/lib/Api.php
imp/lib/Auth.php
imp/lib/Imap.php

index 9c881c5..a4b6576 100644 (file)
@@ -266,7 +266,7 @@ class IMP_Api extends Horde_Registry_Api
             return null;
         }
 
-        $imap_obj = unserialize($_SESSION['imp']['imap_ob']);
+        $imap_obj = unserialize($_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']]);
         return array(
             'hostspec' => $imap_obj->getParam('hostspec'),
             'port' => $imap_obj->getParam('port'),
index 951d0b6..60f34d7 100644 (file)
@@ -181,9 +181,10 @@ class IMP_Auth
      * 'filteravail' - (boolean) Can we apply filters manually?
      * 'imap' - (array) Config for various IMAP resources (acl, admin,
      *          namespace, quota, thread)
+     * 'imap_ob' - (array) The serialized Horde_Imap_Client objects. Stored
+     *             by server key.
      * 'maildomain' - (string) See config/servers.php.
      * 'notepadavail' - (boolean) Is listing of notepads available?
-     * 'ob' - (string) The serialized Horde_Imap_Client object.
      * 'protocol' - (string) Either 'imap' or 'pop'.
      * 'rteavail' - (boolean) Is the HTML editor available?
      * 'search' - (array) Settings used by the IMP_Search library.
index 95cb3e0..fc1739a 100644 (file)
@@ -65,7 +65,7 @@ class IMP_Imap
          * necessary initialization. */
         if ($this->_ob &&
             isset($_SESSION['imp']) &&
-            !isset($_SESSION['imp']['imap_ob'])) {
+            empty($_SESSION['imp']['imap_ob'])) {
             $this->_ob->login();
 
             /* First login may occur on a non-viewable page. However,
@@ -77,7 +77,7 @@ class IMP_Imap
                 $notification->push($alert, 'horde.warning');
             }
 
-            $_SESSION['imp']['imap_ob'] = serialize($this->_ob);
+            $_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']] = serialize($this->_ob);
         }
     }
 
@@ -126,14 +126,15 @@ class IMP_Imap
             return true;
         }
 
-        if (!isset($_SESSION['imp']['imap_ob'])) {
+        if (empty($_SESSION['imp']) ||
+            empty($_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']])) {
             return false;
         }
 
         Horde_Imap_Client::$encryptKey = Horde_Secret::getKey('imp');
 
         $old_error = error_reporting(0);
-        $this->_ob = unserialize($_SESSION['imp']['imap_ob']);
+        $this->_ob = unserialize($_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']]);
         error_reporting($old_error);
 
         if (empty($this->_ob)) {