We always need to search empty namespaces
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 5 Aug 2009 04:00:21 +0000 (22:00 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 5 Aug 2009 04:00:21 +0000 (22:00 -0600)
imp/lib/IMP.php
imp/lib/Imap.php

index aca7bc8..bf2ea25 100644 (file)
@@ -847,7 +847,7 @@ class IMP
      * folders from the personal and any empty namespace, we prefix folders
      * from the empty namespace with the delimiter.
      *
-     * @param string $mailbox  The folder path.
+     * @param string $folder   The folder path.
      * @param boolean $append  True - convert from preference value.
      *                         False - convert to preference value.
      *
@@ -864,7 +864,7 @@ class IMP
                 strpos($folder, $empty_ns['delimiter']) === 0) {
                 /* Prefixed with delimiter => from empty namespace. */
                 $folder = substr($folder, strlen($empty_ns['delimiter']));
-            } elseif (($ns = $GLOBALS['imp_imap']->getNamespace($folder, false)) == null) {
+            } elseif (($ns = $GLOBALS['imp_imap']->getNamespace($folder)) == null) {
                 /* No namespace prefix => from personal namespace. */
                 $folder = $def_ns['name'] . $folder;
             }
@@ -878,6 +878,7 @@ class IMP
                 $folder = $empty_ns['delimiter'] . $folder;
             }
         }
+
         return $folder;
     }
 
index 3411e0f..655a5cc 100644 (file)
@@ -28,13 +28,6 @@ class IMP_Imap
     protected $_readonly = array();
 
     /**
-     * Namespace cache.
-     *
-     * @var array
-     */
-    protected $_nscache = array();
-
-    /**
      * Default namespace.
      *
      * @var array
@@ -328,13 +321,11 @@ class IMP_Imap
      * @param string $mailbox  The folder path. If empty, will return info
      *                         on the default namespace (i.e. the first
      *                         personal namespace).
-     * @param boolean $empty   If true and no matching namespace is found,
-     *                         return the empty namespace, if it exists.
      *
      * @return mixed  The namespace info for the folder path or null if the
      *                path doesn't exist.
      */
-    public function getNamespace($mailbox = null, $empty = true)
+    public function getNamespace($mailbox = null)
     {
         if ($_SESSION['imp']['protocol'] == 'pop') {
             return null;
@@ -347,22 +338,14 @@ class IMP_Imap
             $mailbox = key($ns);
         }
 
-        $key = (int)$empty;
-        if (isset($this->_nscache[$key][$mailbox])) {
-            return $this->_nscache[$key][$mailbox];
-        }
-
         foreach ($ns as $key => $val) {
-            $mbx = $mailbox . $val['delimiter'];
-            if (!empty($key) && (strpos($mbx, $key) === 0)) {
-                $this->_nscache[$key][$mailbox] = $val;
+            $mbox = $mailbox . $val['delimiter'];
+            if (!empty($key) && (strpos($mbox, $key) === 0)) {
                 return $val;
             }
         }
 
-        $this->_nscache[$key][$mailbox] = ($empty && isset($ns[''])) ? $ns[''] : null;
-
-        return $this->_nscache[$key][$mailbox];
+        return isset($ns['']) ? $ns[''] : null;
     }
 
     /**