}
$shares = $this->getShares($shares);
- if (is_null($sort_by)) {
+ if (is_null($params['sort_by'])) {
$this->_sortList = $shares;
uasort($shares, array($this, '_sortShares'));
$this->_sortList = null;
*
* @param Horde_Share_Object $share The new share object.
*
- * @return boolean
* @throws Horde_Share_Exception
*/
public function addShare(Horde_Share_Object $share)
{
// Run the results through the callback, if configured.
$this->runCallback('add', array($share));
- $result = $this->_addShare($share);
+ $this->_addShare($share);
/* Store new share in the caches. */
$id = $share->getId();
/* Reset caches that depend on unknown criteria. */
$this->_listcache = array();
-
- return $result;
}
/**
/* Reset caches that depend on unknown criteria. */
$this->_listcache = array();
- return $this->_removeShare($share);
+ $this->_removeShare($share);
}
/**
*
* @param Horde_Share_Object $share The share to remove.
*
- * @return boolean
* @throws Horde_Share_Exception
*/
abstract protected function _removeShare(Horde_Share_Object $share);
*/
public function toDriverCharset($data)
{
+ return $data;
}
/**
*/
protected function _addShare(Horde_Share_Object $share)
{
- return $this->_datatree->add($share->datatreeObject);
+ Horde_Exception_Pear::catchError($this->_datatree->add($share->datatreeObject));
}
/**
*/
protected function _removeShare(Horde_Share_Object $share)
{
- return $this->_datatree->remove($share->datatreeObject);
+ Horde_Exception_Pear::catchError($this->_datatree->remove($share->datatreeObject));
}
/**
array('field' => 'key', 'op' => 'IN', 'test' => array_keys($groups)),
array('field' => 'value', 'op' => '&', 'test' => $perm)));
}
- } catch (Horde_Group_Exception $e) {}
+ } catch (Horde_Group_Exception $e) {
+ }
} else {
$criteria = array(
'AND' => array(
*/
protected function _addShare(Horde_Share_Object $share)
{
- return $share->save();
+ $share->save();
}
/**
*/
protected function _removeShare(Horde_Share_Object $share)
{
- $share_id = $share->getName();
- $result = $share->delete();
+ $share->delete();
}
/**
/* The value does not matter here as the share will rewrite it */
$share->set('name', '');
- $result = $this->addShare($share);
+ $this->addShare($share);
return $share;
}
* @return Horde_Perms_Permission Permission object that represents the
* permissions on this share
*/
- function getPermission()
+ public function getPermission()
{
$perm = new Horde_Perms_Permission($this->datatreeObject->getName());
$perm->data = isset($this->datatreeObject->data['perm'])
$this->_folder = $folder;
$this->_folder_name = $folder->name;
} else {
- throw new Horde_Share_Exception(Horde_Share_Translation::t("The share has already been initialized!"));
+ throw new Horde_Share_Exception(Horde_Share_Translation::t("The share has already been initialized!"));
}
}
}
/* Now we can reset the children's parent */
- foreach($children as $child) {
+ foreach ($children as $child) {
$child->setParent($this);
}
throw new Horde_Share_Exception($e->getMessage());
}
if (!$results) {
- $this->_logger->err(sprintf('Share name %s not found', $name));
+ $this->_logger->err(sprintf('Share id %s not found', $id));
throw new Horde_Exception_NotFound();
}
$data = $this->_fromDriverCharset($results);
}
$sharelist = array();
- foreach ($shares as $id => $data) {
+ foreach ($shares as $data) {
$this->_getSharePerms($data);
$sharelist[$data['share_name']] = $this->_createObject($data);
}
}
$sharelist = array();
- foreach ($shares as $id => $data) {
+ foreach ($shares as $data) {
$this->_getSharePerms($data);
$sharelist[$data['share_name']] = $this->_createObject($data);
}
}
$sharelist = array();
- foreach ($shares as $id => $data) {
+ foreach ($shares as $data) {
$this->_getSharePerms($data);
$sharelist[$data['share_name']] = $this->_createObject($data);
}
*/
protected function _listShares($userid, array $params = array())
{
+ // We overwrite listShares(), this method is only implemented because
+ // it's abstract in the base class.
}
/**
*/
protected function _addShare(Horde_Share_Object $share)
{
- return $share->save();
+ $share->save();
}
/**
throw new Horde_Share_Exception($e->getMessage());
}
}
-
- return true;
}
/**
$where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_creator', '&', $perm) . ')';
// (name == perm_creator and val & $perm)
- $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default', '&', $perm) . ')';
+ $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default', '&', $perm) . ')';
// (name == perm_users and key == $userid and val & $perm)
$query .= ' LEFT JOIN ' . $this->_table . '_users u ON u.share_id = s.share_id';
*/
protected function _fromDriverCharset($data)
{
- foreach ($data as $key => $value) {
+ foreach ($data as $key => &$value) {
if (substr($key, 0, 9) == 'attribute') {
- $data[$key] = Horde_String::convertCharset(
- $data[$key], $this->_db->getOption('charset'), 'UTF-8');
+ $value = Horde_String::convertCharset(
+ $value, $this->_db->getOption('charset'), 'UTF-8');
}
}
return $data;
}
- foreach ($data as $key => $value) {
+ foreach ($data as $key => &$value) {
if (substr($key, 0, 9) == 'attribute') {
- $data[$key] = Horde_String::convertCharset(
- $data[$key], 'UTF-8', $this->_db->getOption('charset'));
+ $value = Horde_String::convertCharset(
+ $value, 'UTF-8', $this->_db->getOption('charset'));
}
}
* @return string The criteria string for fetching this user's shares.
* @throws Horde_Share_Exception
*/
- public function getShareCriteria($userid, $perm = Horde_Perms::SHOW, $attributes = null,
- $parent = null, $allLevels = true)
+ public function getShareCriteria($userid, $perm = Horde_Perms::SHOW,
+ $attributes = null, $parent = null,
+ $allLevels = true)
{
static $criteria = array();
} else {
$parent_id = $parent;
}
- $key = hash('sha1', serialize(array($userid, $perm, $parent_id, $allLevels, $attributes, $ignorePerms)));
+ $key = hash('sha1', serialize(array($userid, $perm, $parent_id, $allLevels, $attributes)));
if (isset($criteria[$key])) {
return $criteria[$key];
}
$where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_creator', '&', $perm) . ')';
// (name == perm_creator and val & $perm)
- $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default', '&', $perm) . ')';
+ $where .= ' OR (' . Horde_SQL::buildClause($this->_db, 's.perm_default', '&', $perm) . ')';
// (name == perm_users and key == $userid and val & $perm)
$query .= ' LEFT JOIN ' . $this->_table . '_users u ON u.share_id = s.share_id';
return $all_shares;
}
- /**
+ /**
* Removes a share from the shares system permanently. This will recursively
* delete all child shares as well.
*
$children = $share->getChildren(null, null, true);
/* Remove share from the caches. */
- $id = $share->getId();
$this->_cache = array();
$this->_listCache = array();
foreach ($children as $child) {
- $result = $this->_removeShare($child);
+ $this->_removeShare($child);
}
- return $this->_removeShare($share);
+ $this->_removeShare($share);
}
/**
. $this->getShareCriteria($userid, $perm, $attributes, $parent, $allLevels);
try {
- $result = $this->_db->selectValue($query);
+ $this->_db->selectValue($query);
} catch (Horde_Db_Exception $e) {
throw new Horde_Share_Exception($e);
}