* @author Michael J. Rubinsky <mrubinsk@horde.org>
* @package Horde_Share
*/
-class Horde_Share_Base
+abstract class Horde_Share_Base
{
/**
* The application we're managing shares for.
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)
}
/**
+ * 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.
*
}
/**
+ * 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.
*
}
/**
+ * 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.
*
}
/**
+ * 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.
}
/**
+ * 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.
*
* @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)));
}
/**
}
/**
+ * 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
}
/**
+ * 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.
}
/**
+ * 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.
}
/**
+ * 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
*/
public function toDriverCharset($data)
{
- // noop
}
/**