Properties

$_app

$_app : string

The application we're managing shares for.

Type

string

$_root

$_root : mixed

The root of the Share tree.

Type

mixed

$_cache

$_cache : array

A cache of all shares that have been retrieved, so we don't hit the backend again and again for them.

Type

array

$_shareMap

$_shareMap : array

Id-name-map of already cached share objects.

Type

array

$_listcache

$_listcache : array

Cache used for listShares().

Type

array

$_sortList

$_sortList : array

A list of objects that we're currently sorting, for reference during the sorting algorithm.

Type

array

$_shareObject

$_shareObject : string

The Horde_Share_Object subclass to instantiate objects as

Type

string

$_permsObject

$_permsObject : \Horde_Perms_Base

The Horde_Perms object

Type

\Horde_Perms_Base

$_user

$_user : string

The current user

Type

string

$_groups

$_groups : \Horde_Group_Base

The Horde_Group driver

Type

\Horde_Group_Base

$_shareCallback

$_shareCallback : callback

A callback that is passed to the share objects for setting the objects' Horde_Share object.

Type

callback

$_logger

$_logger : \Horde_Log_Logger

Logger

Type

\Horde_Log_Logger

$_callbacks

$_callbacks : array

Configured callbacks. We currently support: <pre> add - Called immediately before a new share is added. Receives the share object as a parameter.

modify - Called immediately before a share object's changes are saved to storage. Receives the share object as a parameter. remove - Called immediately before a share is removed from storage. Receives the share object as a parameter. list - Called immediately after a list of shares is received from storage. Passed the userid, share list, and any parameters passed to the listShare call. Should return the (possibly modified) share list. @see listShares() for more info.

Type

array

Methods

__construct()

__construct(string  $app, string  $user, \Horde_Perms_Base  $perms, \Horde_Group_Base  $groups) 

Constructor.

Parameters

string $app

The application that the shares belong to.

string $user

The current user.

\Horde_Perms_Base $perms

The permissions object.

\Horde_Group_Base $groups

The Horde_Group driver.

setLogger()

setLogger(\Horde_Log_Logger  $logger) 

Set a logger object.

Parameters

\Horde_Log_Logger $logger

initShareObject()

initShareObject(\Horde_Share_Object  $object) 

(Re)connects the share object to this share driver.

Parameters

\Horde_Share_Object $object

setShareCallback()

setShareCallback(  $callback) 

Parameters

$callback

getApp()

getApp() : string

Returns the application we're managing shares for.

Returns

string —

The application this share belongs to.

getShare()

getShare(string  $name) : \Horde_Share_Object

Returns a Horde_Share_Object object corresponding to the given share name, with the details retrieved appropriately.

Parameters

string $name

The name of the share to retrieve.

Returns

\Horde_Share_Object

The requested share.

getShareById()

getShareById(string  $cid) : \Horde_Share_Object

Returns a Horde_Share_Object object corresponding to the given unique ID, with the details retrieved appropriately.

Parameters

string $cid

The id of the share to retrieve.

Returns

\Horde_Share_Object

The requested share.

getShares()

getShares(array  $cids) : array

Returns an array of Horde_Share_Object objects corresponding to the given set of unique IDs, with the details retrieved appropriately.

Parameters

array $cids

The array of ids to retrieve.

Returns

array —

The requested shares.

listAllShares()

listAllShares() : array

Lists *all* shares for the current app/share, regardless of permissions.

This is for admin functionality and scripting tools, and shouldn't be called from user-level code!

Returns

array —

All shares for the current app/share.

listShares()

listShares(string  $userid, array  $params = array()) : array

Returns an array of all shares that $userid has access to.

Parameters

string $userid

The userid of the user to check access for. An empty value for the userid will only return shares with guest access.

array $params

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.

Returns

array —

The shares the user has access to.

listSystemShares()

listSystemShares() : array

Returns an array of all system shares.

Returns

array —

All system shares.

countShares()

countShares(string  $userid, integer  $perm = \Horde_Perms::SHOW, mixed  $attributes = null) : integer

Returns the number of shares that $userid has access to.

Parameters

string $userid

The userid of the user to check access for.

integer $perm

The level of permissions required.

mixed $attributes

Restrict the shares counted to those matching $attributes. An array of attribute/values pairs or a share owner username.

Returns

integer —

The number of shares

newShare()

newShare(string  $owner, string  $share_name = '', string  $name_attribute = '') : \Horde_Share_Object

Returns a new share object.

Parameters

string $owner

The share owner name.

string $share_name

The share's name.

string $name_attribute

The name displayed to the user.

Throws

\Horde_Share_Exception

Returns

\Horde_Share_Object

A new share object.

addShare()

addShare(\Horde_Share_Object  $share) 

Adds a share to the shares system.

The share must first be created with newShare(), and have any initial details added to it, before this function is called.

Parameters

\Horde_Share_Object $share

The new share object.

Throws

\Horde_Share_Exception

fromHash()

fromHash(array  $hash) : \Horde_Share_Object

Adds a share created from a hash.

Parameters

array $hash

A hash like exported from Horde_Share_Object#toHash().

Returns

\Horde_Share_Object

A new share object.

renameShare()

renameShare(\Horde_Share_Object  $share, string  $name) 

Renames a share in the shares system.

Parameters

\Horde_Share_Object $share

The share to rename.

string $name

The share's new name.

Throws

\Horde_Share_Exception

removeShare()

removeShare(\Horde_Share_Object  $share) 

Removes a share from the shares system permanently.

Parameters

\Horde_Share_Object $share

The share to remove.

Throws

\Horde_Share_Exception

exists()

exists(string  $share) : boolean

Checks if a share name exists in the system.

Parameters

string $share

The share name to check.

Returns

boolean —

True if the share exists.

idExists()

idExists(integer  $id) : boolean

Check that a share id exists in the system.

Parameters

integer $id

The share id

Returns

boolean —

True if the share exists.

getPermissions()

getPermissions(mixed  $share, string  $user = null) : mixed

Finds out what rights the given user has to this object.

Parameters

mixed $share

The share that should be checked for the users permissions.

string $user

The user to check for.

Returns

mixed —

A bitmask of permissions, a permission value, or an array of permission values the user has, depending on the permission type and whether the permission value is ambiguous. False if there is no such permsission.

setShareClass()

setShareClass(  $classname) 

Set the class type to use for creating share objects.

Parameters

$classname

getPermsObject()

getPermsObject() : \Horde_Perms_Base

Getter for Horde_Perms object

Returns

\Horde_Perms_Base

toDriverCharset()

toDriverCharset(array  $data) 

Convert TO the storage driver's charset. Individual share objects should implement this method if needed.

Parameters

array $data

Data to be converted.

addCallback()

addCallback(string  $type, array  $callback) 

Add a callback to the collection

Parameters

string $type
array $callback

getListCache()

getListCache() : array

Returns the share's list cache.

Returns

array

setListCache()

setListCache(array  $cache) 

Set the list cache.

Parameters

array $cache

resetCache()

resetCache() 

Resets the internal caches.

runCallback()

runCallback(string  $type, array  $params) : mixed

Give public access to call the share callbacks. Needed to run the callbacks from the Horde_Share_Object objects.

Parameters

string $type

The callback to run

array $params

The parameters to pass to the callback.

Returns

mixed

expireListCache()

expireListCache() 

Expire the current list cache. This would be needed anytime a share is either added, deleted, had a change in owner, parent, or perms.

_getShare()

_getShare(string  $name) : \Horde_Share_Object

Returns a Horde_Share_Object object corresponding to the given share name, with the details retrieved appropriately.

Parameters

string $name

The name of the share to retrieve.

Throws

\Horde_Exception_NotFound
\Horde_Share_Exception

Returns

\Horde_Share_Object

The requested share.

_getShareById()

_getShareById(integer  $id) : \Horde_Share_Object_sql

Returns a Horde_Share_Object object corresponding to the given unique ID, with the details retrieved appropriately.

Parameters

integer $id

The id of the share to retrieve.

Throws

\Horde_Share_Exception,

Horde_Exception_NotFound

Returns

\Horde_Share_Object_sql —

The requested share.

_getShares()

_getShares(array  $ids) : array

Returns an array of Horde_Share_Object objects corresponding to the given set of unique IDs, with the details retrieved appropriately.

Parameters

array $ids

The array of ids to retrieve.

Throws

\Horde_Share_Exception

Returns

array —

The requested shares.

_listAllShares()

_listAllShares() : array

Lists *all* shares for the current app/share, regardless of permissions.

Throws

\Horde_Share_Exception

Returns

array —

All shares for the current app/share.

_listShares()

_listShares(string  $userid, array  $params = array()) : array

Returns an array of all shares that $userid has access to.

Parameters

string $userid

The userid of the user to check access for.

array $params

See listShares().

Returns

array —

The shares the user has access to.

_newShare()

_newShare(string  $name) : \Horde_Share_Object

Returns a new share object.

Parameters

string $name

The share's name.

Throws

\InvalidArgumentException

Returns

\Horde_Share_Object

A new share object

_addShare()

_addShare(\Horde_Share_Object  $share) 

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.

Parameters

\Horde_Share_Object $share

The new share object.

_renameShare()

_renameShare(\Horde_Share_Object  $share, string  $name) 

Renames a share in the shares system.

Parameters

\Horde_Share_Object $share

The share to rename.

string $name

The share's new name.

Throws

\Horde_Share_Exception

_removeShare()

_removeShare(\Horde_Share_Object  $share) 

Removes a share from the shares system permanently.

Parameters

\Horde_Share_Object $share

The share to remove.

Throws

\Horde_Share_Exception

_exists()

_exists(string  $share) : boolean

Checks if a share exists in the system.

Parameters

string $share

The share to check.

Throws

\Horde_Share_Exception

Returns

boolean —

True if the share exists.

_idExists()

_idExists(integer  $id) : boolean

Check that a share id exists in the system.

Parameters

integer $id

The share id

Returns

boolean —

True if the share exists.

_sortShares()

_sortShares(  $a,   $b) 

Utility function to be used with uasort() for sorting arrays of Horde_Share objects.

Example: uasort($list, array('Horde_Share', '_sortShares'));

Parameters

$a
$b