Fix name handling.
authorGunnar Wrobel <p@rdus.de>
Fri, 12 Mar 2010 22:42:13 +0000 (23:42 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Mon, 15 Mar 2010 10:33:20 +0000 (11:33 +0100)
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder.php
framework/Kolab_Storage/test/Horde/Kolab/Storage/NamespaceTest.php

index a35ac90..dcd3c18 100644 (file)
@@ -238,9 +238,14 @@ class Horde_Kolab_Storage_Folder
      *
      * @return string The name of the folder.
      */
-    function getName()
+    public function getName()
     {
-        return $this->name;
+        if (isset($this->name)) {
+            return $this->name;
+        }
+        if (!isset($this->name) && isset($this->new_name)) {
+            return $this->new_name;
+        }
     }
 
     /**
@@ -480,14 +485,10 @@ class Horde_Kolab_Storage_Folder
      *
      * @return string|PEAR_Error  The owner of this folder.
      */
-    function getOwner()
+    public function getOwner()
     {
         if (!isset($this->_owner)) {
-            if (!isset($this->name) && isset($this->new_name)) {
-                $this->_owner = $this->_namespace->getOwner($this->new_name);
-            } else {
-                $this->_owner = $this->_namespace->getOwner($this->name);
-            }
+            $this->_owner = $this->_namespace->getOwner($this->getName());
         }
         return $this->_owner;
     }
@@ -525,10 +526,10 @@ class Horde_Kolab_Storage_Folder
      *
      * @return string  The folder title.
      */
-    function getTitle()
+    public function getTitle()
     {
-        if (!isset($this->_title) && isset($this->name)) {
-            $this->_title = $this->_namespace->getTitle($this->name);
+        if (!isset($this->_title)) {
+            $this->_title = $this->_namespace->getTitle($this->getName());
         }
         return $this->_title;
     }
index 539fa1e..4e59e6a 100644 (file)
@@ -81,6 +81,17 @@ class Horde_Kolab_Storage_NamespaceTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('äöü', $folder->getTitle());
     }
 
+    public function testFolderTitleIsAccessibleForNewFolders()
+    {
+        $_SESSION['horde_auth']['userId'] = 'test';
+        $folder = new Horde_Kolab_Storage_Folder(
+            null,
+            new Horde_Kolab_Storage_Namespace()
+        );
+        $folder->setName('test');
+        $this->assertEquals('test', $folder->getTitle());
+    }
+
     public function testFolderOwnerIsCurrentUserIfPrefixMatchesPrivateNamespace()
     {
         $this->markTestIncomplete('This expectation currently does not hold as we are not using the namespace handler yet.');