From: Gunnar Wrobel Date: Sat, 8 Jan 2011 20:32:53 +0000 (+0100) Subject: Cached folder owner list. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b717b02b2c0ed8f2d6abac5343c49de6cdcb971a;p=horde.git Cached folder owner list. --- diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query.php index d12b470ac..4269c7a37 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query.php @@ -59,7 +59,7 @@ extends Horde_Kolab_Storage_Query * @return array The folder owners with the folder names as key and the * owner as values. */ -// public function listOwners(); + public function listOwners(); /** * Get the default folder for a certain type. diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php index de3a29924..714c98f46 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/List/Query/Cache.php @@ -34,6 +34,9 @@ implements Horde_Kolab_Storage_List_Query /** The folder list sorted by type */ const BY_TYPE = 'BY_TYPE'; + /** The folder owner list */ + const OWNERS = 'OWNERS'; + /** * The queriable list. * @@ -115,6 +118,17 @@ implements Horde_Kolab_Storage_List_Query } /** + * Get the folder owners. + * + * @return array The folder owners with the folder names as key and the + * owner as values. + */ + public function listOwners() + { + return $this->_list_cache->getQuery(self::OWNERS); + } + + /** * Synchronize the query data with the information from the backend. * * @return NULL @@ -130,5 +144,12 @@ implements Horde_Kolab_Storage_List_Query } $this->_list_cache->setQuery(self::TYPES, $types); $this->_list_cache->setQuery(self::BY_TYPE, $by_type); + + $owners = array(); + $namespace = $this->_list->getNamespace(); + foreach ($this->_list->listFolders() as $folder) { + $owners[$folder] = $namespace->getOwner($folder); + } + $this->_list_cache->setQuery(self::OWNERS, $owners); } } \ No newline at end of file diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php index 0be91df6f..c1f6df303 100644 --- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php +++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/Unit/List/Query/CacheTest.php @@ -94,4 +94,53 @@ extends Horde_Kolab_Storage_TestCase $this->assertEquals(array('INBOX/Tasks'), $query->listByType('task')); } + public function testListOwnersReturn() + { + $factory = new Horde_Kolab_Storage_Factory(); + $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory); + $this->assertType( + 'array', + $query->listOwners() + ); + } + + public function testListOwnerList() + { + $factory = new Horde_Kolab_Storage_Factory(); + $query = $this->getCachedQueryForList($this->getAnnotatedList($factory), $factory); + $this->assertEquals( + array( + 'INBOX' => 'test@example.com', + 'INBOX/Calendar' => 'test@example.com', + 'INBOX/Contacts' => 'test@example.com', + 'INBOX/Notes' => 'test@example.com', + 'INBOX/Tasks' => 'test@example.com', + 'INBOX/a' => 'test@example.com', + ), + $query->listOwners() + ); + } + + public function testListOwnerNamespace() + { + $factory = new Horde_Kolab_Storage_Factory(); + $query = $this->getCachedQueryForList($this->getNamespaceList($factory), $factory); + $this->assertEquals( + array( + 'INBOX' => 'test@example.com', + 'INBOX/Calendar' => 'test@example.com', + 'INBOX/Contacts' => 'test@example.com', + 'INBOX/Notes' => 'test@example.com', + 'INBOX/Tasks' => 'test@example.com', + 'INBOX/a' => 'test@example.com', + 'shared.Calendars/All' => 'anonymous', + 'shared.Calendars/Others' => 'anonymous', + 'user/example/Calendar' => 'example@example.com', + 'user/example/Notes' => 'example@example.com', + 'user/someone/Calendars/Events' => 'someone@example.com', + 'user/someone/Calendars/Party' => 'someone@example.com', + ), + $query->listOwners() + ); + } }