Cache the namespace handler.
authorGunnar Wrobel <p@rdus.de>
Fri, 17 Dec 2010 22:04:40 +0000 (23:04 +0100)
committerGunnar Wrobel <p@rdus.de>
Tue, 4 Jan 2011 07:54:10 +0000 (08:54 +0100)
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Base.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Imap.php

index 1d5a2ba..a555781 100644 (file)
@@ -43,6 +43,13 @@ implements Horde_Kolab_Storage_Driver
     private $_params;
 
     /**
+     * Memory cache for the namespace of this driver.
+     *
+     * @var Horde_Kolab_Storage_Folder_Namespace
+     */
+    protected $_namespace;
+
+    /**
      * Constructor.
      *
      * @param Horde_Kolab_Storage_Factory $factory A factory for helper objects.
@@ -86,11 +93,15 @@ implements Horde_Kolab_Storage_Driver
      */
     public function getNamespace()
     {
-        if (isset($this->_params['namespaces'])) {
-            return $factory->createNamespace(
-                'config', $this->_params['namespaces']
-            );
+        if ($this->_namespace === null) {
+            if (isset($this->_params['namespaces'])) {
+                $this->_namespace = $this->_factory->createNamespace(
+                    'config', $this->_params['namespaces']
+                );
+            } else {
+                $this->_namespace = $this->_factory->createNamespace('fixed');
+            }
         }
-        return $this->_factory->createNamespace('fixed');
+        return $this->_namespace;
     }
 }
\ No newline at end of file
index d070c59..f8f3bbd 100644 (file)
@@ -285,15 +285,15 @@ extends Horde_Kolab_Storage_Driver_Base
         if ($this->_imap->queryCapability('ACL') === true) {
             if ($folder->getOwner() == $this->getAuth()) {
                 try {
-                    return $this->_getAcl($folder->getName());
+                    return $this->_getAcl($folder->getPath());
                 } catch (Exception $e) {
-                    return array($this->getAuth() => $this->_getMyAcl($folder->getName()));
+                    return array($this->getAuth() => $this->_getMyAcl($folder->getPath()));
                 }
             } else {
-                $acl = $this->_getMyAcl($folder->getName());
+                $acl = $this->_getMyAcl($folder->getPath());
                 if (strpos($acl, 'a')) {
                     try {
-                        return $this->_getAcl($folder->getName());
+                        return $this->_getAcl($folder->getPath());
                     } catch (Exception $e) {
                     }
                 }
@@ -407,7 +407,8 @@ extends Horde_Kolab_Storage_Driver_Base
      */
     public function getNamespace()
     {
-        if ($this->_imap->queryCapability('NAMESPACE') === true) {
+        if ($this->_namespace === null
+            && $this->_imap->queryCapability('NAMESPACE') === true) {
             $c = array();
             $configuration = $this->getParam('namespaces', array());
             foreach ($this->_imap->getNamespaces() as $namespace) {
@@ -416,7 +417,7 @@ extends Horde_Kolab_Storage_Driver_Base
                 }
                 $c[] = $namespace;
             }
-            return $this->getFactory()->createNamespace('imap', $c);
+            $this->_namespace = $this->getFactory()->createNamespace('imap', $c);
         }
         return parent::getNamespace();
     }