const VERSION = 1;
/**
- * Our Kolab folder list handler
+ * The Kolab storage handler
*
- * @var Kolab_List
+ * @var Horde_Kolab_Storage
*/
- protected $_list;
+ protected $_storage;
/**
* The share type
protected $_listCacheValidity;
/**
- * The session handler.
+ * Set the Kolab storage backend.
*
- * @var Horde_Kolab_Session
+ * @param Horde_Kolab_Storage $driver The Kolab storage driver.
+ *
+ * @return NULL
*/
- protected $_session;
+ public function setStorage(Horde_Kolab_Storage $driver)
+ {
+ $this->_storage = $driver;
+ }
+ /**
+ * Return the Kolab storage backend associated with this driver.
+ *
+ * @return Horde_Kolab_Storage The Kolab storage driver.
+ */
+ public function getStorage()
+ {
+ if ($this->_storage === null) {
+ throw new Horde_Share_Exception('The storage backend has not yet been set!');
+ }
+ return $this->_storage;
+ }
private function _getFolderType($app)
{
}
/**
- * Set the kolab storage backend.
- *
- * @param Horde_Kolab_Storage $driver
- */
- public function setStorage(Horde_Kolab_Storage $driver)
- {
- $this->_list = $driver;
- }
-
- public function getStorage()
- {
- return $this->_list;
- }
-
- /**
* Returns a Horde_Share_Object_kolab object of the request folder.
*
* @param string $object The share to fetch.
}
/* Get the corresponding folder for this share ID */
- $folder = $this->_list->getByShare($object, $this->_type);
+ $folder = $this->_storage->getByShare($object, $this->_type);
/* Does the folder exist? */
if (!$folder->exists()) {
protected function _listShares($userid, array $params = array())
{
$key = serialize(array($this->_type, $userid, $params['perm'], $params['attributes']));
- if ($this->_list === false) {
+ if ($this->_storage === false) {
$this->_listCache[$key] = array();
} else if (empty($this->_listCache[$key])
|| $this->_list->validity != $this->_listCacheValidity) {
- $sharelist = $this->_list->getByType($this->_type);
+ $sharelist = $this->_storage->getByType($this->_type);
if ($sharelist instanceof PEAR_Error) {
throw new Horde_Share_Exception($sharelist->getMessage());
}
}
}
$this->_listCache[$key] = $shares;
- $this->_listCacheValidity = $this->_list->validity;
+ $this->_listCacheValidity = $this->_storage->validity;
}
return $this->_listCache[$key];
}
/* Get the corresponding folder for this share ID */
- $folder = $this->_list->getByShare($object, $this->_type);
+ $folder = $this->_storage->getByShare($object, $this->_type);
if ($folder instanceof PEAR_Error) {
throw new Horde_Share_Exception($folder->getMessage());
}
*/
public function getDefaultShare()
{
- $default = $this->_list->getDefault($this->_type);
+ $default = $this->_storage->getDefault($this->_type);
if ($default instanceof PEAR_Error) {
throw new Horde_Share_Exception($default->getMessage());
}
extends PHPUnit_Framework_TestCase
{
- public function test()
+ public function testGetStorage()
{
+ $storage = $this->getMock('Horde_Kolab_Storage');
+ $driver = $this->_getDriver();
+ $driver->setStorage($storage);
+ $this->assertSame($storage, $driver->getStorage());
}
+ /**
+ * @expectedException Horde_Share_Exception
+ */
+ public function testStorageMissing()
+ {
+ $driver = $this->_getDriver();
+ $driver->getStorage();
+ }
+
+ private function _getDriver()
+ {
+ return new Horde_Share_Kolab(
+ 'test', 'john', new Horde_Perms(), new Horde_Group_Test()
+ );
+ }
}
\ No newline at end of file