Bug #8948: Fix namespace stripping for pref values
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 16 Apr 2010 19:37:15 +0000 (13:37 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 16 Apr 2010 19:37:15 +0000 (13:37 -0600)
imp/lib/IMP.php
imp/lib/Imap.php

index 1b96388..280fb1f 100644 (file)
@@ -734,11 +734,11 @@ 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)) == null) {
+            } elseif (($ns = $GLOBALS['imp_imap']->getNamespace($folder, true)) == null) {
                 /* No namespace prefix => from personal namespace. */
                 $folder = $def_ns['name'] . $folder;
             }
-        } elseif (!$append && (($ns = $GLOBALS['imp_imap']->getNamespace($folder)) !== null)) {
+        } elseif (($ns = $GLOBALS['imp_imap']->getNamespace($folder)) !== null) {
             /* Converting to preference value. */
             if ($ns['name'] == $def_ns['name']) {
                 /* From personal namespace => strip namespace. */
index 21b980f..eeb029f 100644 (file)
@@ -361,14 +361,14 @@ class IMP_Imap
     /**
      * Get namespace info for a full folder path.
      *
-     * @param string $mailbox  The folder path. If empty, will return info
-     *                         on the default namespace (i.e. the first
-     *                         personal namespace).
+     * @param string $mailbox    The folder path.
+     * @param boolean $personal  If true, will return empty namespace only
+     *                           if it is a personal namespace.
      *
      * @return mixed  The namespace info for the folder path or null if the
      *                path doesn't exist.
      */
-    public function getNamespace($mailbox = null)
+    public function getNamespace($mailbox = null, $personal = false)
     {
         if ($_SESSION['imp']['protocol'] == 'pop') {
             return null;
@@ -388,7 +388,9 @@ class IMP_Imap
             }
         }
 
-        return isset($ns['']) ? $ns[''] : null;
+        return (isset($ns['']) && (!$personal || ($val['type'] == 'personal')))
+            ? $ns['']
+            : null;
     }
 
     /**