From: Gunnar Wrobel Date: Sat, 15 Jan 2011 22:46:15 +0000 (+0100) Subject: Folder type support. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=19588714348d52427daaf4c8f56f2a79eaf4b7ba;p=horde.git Folder type support. --- diff --git a/framework/Share/lib/Horde/Share/Kolab.php b/framework/Share/lib/Horde/Share/Kolab.php index 90b97b3f1..82404fb78 100644 --- a/framework/Share/lib/Horde/Share/Kolab.php +++ b/framework/Share/lib/Horde/Share/Kolab.php @@ -27,7 +27,7 @@ class Horde_Share_Kolab extends Horde_Share_Base protected $_storage; /** - * The share type + * The folder type in the storage backend. * * @var string */ @@ -41,6 +41,36 @@ class Horde_Share_Kolab extends Horde_Share_Base protected $_listCacheValidity; /** + * Constructor. + * + * @param string $app The application that the shares belong to + * @param string $user The current user + * @param Horde_Perms $perms The permissions object + * @param Horde_Group $groups The Horde_Group object + * + */ + public function __construct($app, $user, Horde_Perms $perms, Horde_Group $groups) + { + switch ($app) { + case 'mnemo': + $this->_type = 'note'; + break; + case 'kronolith': + $this->_type = 'event'; + break; + case 'turba': + $this->_type = 'contact'; + break; + case 'nag': + $this->_type = 'task'; + break; + default: + throw new Horde_Share_Exception(sprintf(Horde_Share_Translation::t("The Horde/Kolab integration engine does not support \"%s\""), $app)); + } + parent::__construct($app, $user, $perms, $groups); + } + + /** * Set the Kolab storage backend. * * @param Horde_Kolab_Storage $driver The Kolab storage driver. @@ -138,23 +168,17 @@ class Horde_Share_Kolab extends Horde_Share_Base return array(); } - - private function _getFolderType($app) + /** + * Return the type of folder this share driver will access in the Kolab + * storage backend (depends on the application calling the share driver). + * + * @return string + */ + public function getType() { - switch ($app) { - case 'mnemo': - return 'note'; - case 'kronolith': - return 'event'; - case 'turba': - return 'contact'; - case 'nag': - return 'task'; - default: - throw new Horde_Share_Exception(sprintf(Horde_Share_Translation::t("The Horde/Kolab integration engine does not support \"%s\""), $app)); - } + return $this->_type; } - + /** * (re)connect the share object to this share driver. Userful for when * share objects are unserialized from a cache separate from the share diff --git a/framework/Share/test/Horde/Share/Kolab/UnitTest.php b/framework/Share/test/Horde/Share/Kolab/UnitTest.php index b75bedbe6..4eafbd937 100644 --- a/framework/Share/test/Horde/Share/Kolab/UnitTest.php +++ b/framework/Share/test/Horde/Share/Kolab/UnitTest.php @@ -67,6 +67,51 @@ extends PHPUnit_Framework_TestCase ); } + public function testGetTypeString() + { + $driver = new Horde_Share_Kolab( + 'mnemo', 'john', new Horde_Perms(), new Horde_Group_Test() + ); + $this->assertType('string', $driver->getType()); + } + + public function testMnemoSupport() + { + $driver = new Horde_Share_Kolab( + 'mnemo', 'john', new Horde_Perms(), new Horde_Group_Test() + ); + $this->assertEquals('note', $driver->getType()); + } + + public function testKronolithSupport() + { + $driver = new Horde_Share_Kolab( + 'kronolith', 'john', new Horde_Perms(), new Horde_Group_Test() + ); + $this->assertEquals('event', $driver->getType()); + } + + public function testTurbaSupport() + { + $driver = new Horde_Share_Kolab( + 'turba', 'john', new Horde_Perms(), new Horde_Group_Test() + ); + $this->assertEquals('contact', $driver->getType()); + } + + public function testNagSupport() + { + $driver = new Horde_Share_Kolab( + 'nag', 'john', new Horde_Perms(), new Horde_Group_Test() + ); + $this->assertEquals('task', $driver->getType()); + } + + /** + * @todo: Reminder: Check that external modification of the Storage system + * works (former list->validity). + */ + private function _getCompleteDriver() { $factory = new Horde_Kolab_Storage_Factory(); @@ -88,7 +133,7 @@ extends PHPUnit_Framework_TestCase private function _getDriver() { return new Horde_Share_Kolab( - 'test', 'john', new Horde_Perms(), new Horde_Group_Test() + 'mnemo', 'john', new Horde_Perms(), new Horde_Group_Test() ); } } \ No newline at end of file