Horde_Share_Base::listShares PHP Method

listShares() public method

Returns an array of all shares that $userid has access to.
public listShares ( string $userid, array $params = [] ) : array
$userid string The userid of the user to check access for. An empty value for the userid will only return shares with guest access.
$params array Additional parameters for the search.
 'perm'        Require this level of permissions. Horde_Perms constant.
 'attributes'  Restrict shares to these attributes. A hash or username.
 'from'        Offset. Start at this share
 'count'       Limit.  Only return this many.
 'sort_by'     Sort by attribute.
 'direction'   Sort by direction.
return array The shares the user has access to.
    public function listShares($userid, array $params = array())
    {
        $params = array_merge(array('perm' => Horde_Perms::SHOW, 'attributes' => null, 'from' => 0, 'count' => 0, 'sort_by' => null, 'direction' => 0), $params);
        $shares = $this->_listShares($userid, $params);
        if (!count($shares)) {
            return $shares;
        }
        $shares = $this->getShares($shares);
        if (is_null($params['sort_by'])) {
            $this->_sortList = $shares;
            uasort($shares, array($this, '_sortShares'));
            $this->_sortList = null;
        }
        // Run the results through the callback, if configured.
        if (!empty($this->_callbacks['list'])) {
            return $this->runCallback('list', array($userid, $shares, $params));
        }
        return $shares;
    }

Usage Example

Example #1
0
 /**
  * Returns the default share's ID, if it can be determined from the share
  * backend.
  *
  * @return string  The default share ID.
  */
 public function getDefaultShare()
 {
     $shares = $this->_shares->listShares($this->_user, array('attributes' => $this->_user));
     foreach ($shares as $id => $share) {
         if ($share->get('default')) {
             return $id;
         }
     }
 }