From: Jan Schneider Date: Thu, 16 Dec 2010 20:59:23 +0000 (+0100) Subject: Make Horde_Share_Base abstract. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d63ec9e995f1352930b1647d1c732882cb0e8cd1;p=horde.git Make Horde_Share_Base abstract. --- diff --git a/framework/Share/lib/Horde/Share/Base.php b/framework/Share/lib/Horde/Share/Base.php index eba271650..7dd23a78b 100644 --- a/framework/Share/lib/Horde/Share/Base.php +++ b/framework/Share/lib/Horde/Share/Base.php @@ -16,7 +16,7 @@ * @author Michael J. Rubinsky * @package Horde_Share */ -class Horde_Share_Base +abstract class Horde_Share_Base { /** * The application we're managing shares for. @@ -163,12 +163,6 @@ class Horde_Share_Base public function initShareObject(Horde_Share_Object $object) { $object->setShareOb($this->_shareCallback); - $this->_initShareObject($object); - } - - protected function _initShareObject(Horde_Share_Object $object) - { - // noop here } public function setShareCallback($callback) @@ -208,6 +202,18 @@ class Horde_Share_Base } /** + * Returns a Horde_Share_Object_sql object corresponding to the given + * share name, with the details retrieved appropriately. + * + * @param string $name The name of the share to retrieve. + * + * @return Horde_Share_Object The requested share. + * @throws Horde_Exception_NotFound + * @throws Horde_Share_Exception + */ + abstract protected function _getShare($name); + + /** * Returns a Horde_Share_Object object corresponding to the given unique * ID, with the details retrieved appropriately. * @@ -228,6 +234,17 @@ class Horde_Share_Base } /** + * Returns a Horde_Share_Object_sql object corresponding to the given + * unique ID, with the details retrieved appropriately. + * + * @param integer $id The id of the share to retrieve. + * + * @return Horde_Share_Object_sql The requested share. + * @throws Horde_Share_Exception, Horde_Exception_NotFound + */ + abstract protected function _getShareById($id); + + /** * Returns an array of Horde_Share_Object objects corresponding to the * given set of unique IDs, with the details retrieved appropriately. * @@ -259,6 +276,18 @@ class Horde_Share_Base } /** + * Returns an array of Horde_Share_Object_sql objects corresponding + * to the given set of unique IDs, with the details retrieved + * appropriately. + * + * @param array $ids The array of ids to retrieve. + * + * @return array The requested shares. + * @throws Horde_Share_Exception + */ + abstract protected function _getShares(array $ids); + + /** * Lists *all* shares for the current app/share, regardless of * permissions. * @@ -278,6 +307,14 @@ class Horde_Share_Base } /** + * Lists *all* shares for the current app/share, regardless of permissions. + * + * @return array All shares for the current app/share. + * @throws Horde_Share_Exception + */ + abstract protected function _listAllShares(); + + /** * Returns an array of all shares that $userid has access to. * * @param string $userid The userid of the user to check access for. @@ -324,6 +361,16 @@ class Horde_Share_Base } /** + * Returns an array of all shares that $userid has access to. + * + * @param string $userid The userid of the user to check access for. + * @param array $params See listShares(). + * + * @return array The shares the user has access to. + */ + abstract protected function _listShares($userid, $params = array()); + + /** * Returns an array of all system shares. * * @return array All system shares. @@ -345,9 +392,10 @@ class Horde_Share_Base * * @return integer The number of shares */ - public function countShares($userid, $perm = Horde_Perms::SHOW, $attributes = null) + public function countShares($userid, $perm = Horde_Perms::SHOW, + $attributes = null) { - return $this->_countShares($userid, $perm, $attributes); + return count($this->_listShares($userid, array('perm' => $perm, 'attributes' => $attributes))); } /** @@ -369,6 +417,16 @@ class Horde_Share_Base } /** + * Returns a new share object. + * + * @param string $name The share's name. + * + * @return Horde_Share_Object A new share object + * @throws InvalidArgumentException + */ + abstract protected function _newShare($name); + + /** * Adds a share to the shares system. * * The share must first be created with newShare(), and have any initial @@ -398,6 +456,17 @@ class Horde_Share_Base } /** + * Adds a share to the shares system. + * + * The share must first be created with + * Horde_Share_sql::_newShare(), and have any initial details added + * to it, before this function is called. + * + * @param Horde_Share_Object $share The new share object. + */ + abstract protected function _addShare(Horde_Share_Object $share); + + /** * Removes a share from the shares system permanently. * * @param Horde_Share_Object $share The share to remove. @@ -421,6 +490,16 @@ class Horde_Share_Base } /** + * Removes a share from the shares system permanently. + * + * @param Horde_Share_Object $share The share to remove. + * + * @return boolean + * @throws Horde_Share_Exception + */ + abstract protected function _removeShare(Horde_Share_Object $share); + + /** * Checks if a share exists in the system. * * @param string $share The share to check. @@ -437,6 +516,16 @@ class Horde_Share_Base } /** + * Checks if a share exists in the system. + * + * @param string $share The share to check. + * + * @return boolean True if the share exists. + * @throws Horde_Share_Exception + */ + abstract protected function _exists($share); + + /** * Finds out what rights the given user has to this object. * * @see Horde_Perms::getPermissions @@ -487,7 +576,6 @@ class Horde_Share_Base */ public function toDriverCharset($data) { - // noop } /** diff --git a/framework/Share/lib/Horde/Share/Kolab.php b/framework/Share/lib/Horde/Share/Kolab.php index 1fe20a669..c8e95e6d3 100644 --- a/framework/Share/lib/Horde/Share/Kolab.php +++ b/framework/Share/lib/Horde/Share/Kolab.php @@ -219,25 +219,6 @@ class Horde_Share_Kolab extends Horde_Share_Base } /** - * Returns the number of shares that $userid has access to. - * - * @param string $userid The userid of the user to check access for. - * @param integer $perm The level of permissions required. - * @param mixed $attributes Restrict the shares counted to those - * matching $attributes. An array of - * attribute/values pairs or a share owner - * username. - * - * @return integer The number of shares - */ - protected function _countShares($userid, $perm = Horde_Perms::SHOW, - $attributes = null) - { - $shares = $this->_listShares($userid, array('perm' => $perm, 'attributes' => $attributes)); - return count($shares); - } - - /** * Returns a new share object. * * @param string $name The share's name. diff --git a/framework/Share/lib/Horde/Share/Sql.php b/framework/Share/lib/Horde/Share/Sql.php index 7089f7e10..6bb7869d9 100644 --- a/framework/Share/lib/Horde/Share/Sql.php +++ b/framework/Share/lib/Horde/Share/Sql.php @@ -456,6 +456,18 @@ class Horde_Share_Sql extends Horde_Share_Base } /** + * Returns an array of all shares that $userid has access to. + * + * @param string $userid The userid of the user to check access for. + * @param array $params See listShares(). + * + * @return array The shares the user has access to. + */ + protected function _listShares($userid, $params = array()) + { + } + + /** * Returns an array of all system shares. * * @return array All system shares. @@ -493,8 +505,8 @@ class Horde_Share_Sql extends Horde_Share_Base * @return integer The number of shares * @throws Horde_Share_Exception */ - protected function _countShares($userid, $perm = Horde_Perms::SHOW, - $attributes = null) + public function countShares($userid, $perm = Horde_Perms::SHOW, + $attributes = null) { $query = 'SELECT COUNT(DISTINCT s.share_id) ' . $this->getShareCriteria($userid, $perm, $attributes);