PHP Class Horde_Share_Base, horde

Copyright 2002-2016 Horde LLC (http://www.horde.org/) Copyright 2002-2007 Infoteck Internet See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Joel Vandal ([email protected])
Author: Mike Cochrame ([email protected])
Author: Chuck Hagenbuch ([email protected])
Author: Jan Schneider ([email protected])
Author: Gunnar Wrobel ([email protected])
Author: Michael J. Rubinsky ([email protected])
Show file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_app string The application we're managing shares for.
$_cache array A cache of all shares that have been retrieved, so we don't hit the backend again and again for them.
$_callbacks array 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.
$_groups Horde_Group_Base The Horde_Group driver
$_listcache array Cache used for listShares().
$_logger Horde_Log_Logger Logger
$_permsObject Horde_Perms_Base The Horde_Perms object
$_root mixed The root of the Share tree.
$_shareCallback callback A callback that is passed to the share objects for setting the objects' Horde_Share object.
$_shareMap array Id-name-map of already cached share objects.
$_shareObject string The Horde_Share_Object subclass to instantiate objects as
$_sortList array A list of objects that we're currently sorting, for reference during the sorting algorithm.
$_user string The current user

Public Methods

Method Description
__construct ( string $app, string $user, Horde_Perms_Base $perms, Horde_Group_Base $groups ) Constructor.
addCallback ( string $type, array $callback ) Add a callback to the collection
addShare ( Horde_Share_Object $share ) Adds a share to the shares system.
countShares ( string $userid, integer $perm = Horde_Perms::SHOW, mixed $attributes = null ) : integer Returns the number of shares that $userid has access to.
exists ( string $share ) : boolean Checks if a share name exists in the system.
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.
getApp ( ) : string Returns the application we're managing shares for.
getListCache ( ) : array Returns the share's list cache.
getPermissions ( mixed $share, string $user = null ) : mixed Finds out what rights the given user has to this object.
getPermsObject ( ) : Horde_Perms_Base Getter for Horde_Perms object
getShare ( string $name ) : Horde_Share_Object Returns a Horde_Share_Object object corresponding to the given share name, with the details retrieved appropriately.
getShareById ( string $cid ) : Horde_Share_Object Returns a Horde_Share_Object object corresponding to the given unique ID, with the details retrieved appropriately.
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.
idExists ( integer $id ) : boolean Check that a share id exists in the system.
initShareObject ( Horde_Share_Object $object ) (Re)connects the share object to this share driver.
listAllShares ( ) : array Lists *all* shares for the current app/share, regardless of permissions.
listShares ( string $userid, array $params = [] ) : array Returns an array of all shares that $userid has access to.
listSystemShares ( ) : array Returns an array of all system shares.
newShare ( string $owner, string $share_name = '', string $name_attribute = '' ) : Horde_Share_Object Returns a new share object.
removeShare ( Horde_Share_Object $share ) Removes a share from the shares system permanently.
renameShare ( Horde_Share_Object $share, string $name ) Renames a share in the shares system.
resetCache ( ) Resets the internal caches.
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.
setListCache ( array $cache ) Set the list cache.
setLogger ( Horde_Log_Logger $logger ) Set a logger object.
setShareCallback ( $callback )
setShareClass ( $classname ) Set the class type to use for creating share objects.
toDriverCharset ( array $data ) Convert TO the storage driver's charset. Individual share objects should implement this method if needed.

Protected Methods

Method Description
_addShare ( Horde_Share_Object $share ) Adds a share to the shares system.
_exists ( string $share ) : boolean Checks if a share exists in the system.
_getShare ( string $name ) : Horde_Share_Object Returns a Horde_Share_Object object corresponding to the given share name, with the details retrieved appropriately.
_getShareById ( integer $id ) : Horde_Share_Object_sql Returns a Horde_Share_Object object corresponding to the given unique ID, with the details retrieved appropriately.
_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.
_idExists ( integer $id ) : boolean Check that a share id exists in the system.
_listAllShares ( ) : array Lists *all* shares for the current app/share, regardless of permissions.
_listShares ( string $userid, array $params = [] ) : array Returns an array of all shares that $userid has access to.
_newShare ( string $name ) : Horde_Share_Object Returns a new share object.
_removeShare ( Horde_Share_Object $share ) Removes a share from the shares system permanently.
_renameShare ( Horde_Share_Object $share, string $name ) Renames a share in the shares system.
_sortShares ( $a, $b ) Utility function to be used with uasort() for sorting arrays of Horde_Share objects.

Method Details

__construct() public method

Constructor.
public __construct ( string $app, string $user, Horde_Perms_Base $perms, Horde_Group_Base $groups )
$app string The application that the shares belong to.
$user string The current user.
$perms Horde_Perms_Base The permissions object.
$groups Horde_Group_Base The Horde_Group driver.

_addShare() abstract protected method

The share must first be created with Horde_Share_sql::_newShare(), and have any initial details added to it, before this function is called.
abstract protected _addShare ( Horde_Share_Object $share )
$share Horde_Share_Object The new share object.

_exists() abstract protected method

Checks if a share exists in the system.
abstract protected _exists ( string $share ) : boolean
$share string The share to check.
return boolean True if the share exists.

_getShare() abstract protected method

Returns a Horde_Share_Object object corresponding to the given share name, with the details retrieved appropriately.
abstract protected _getShare ( string $name ) : Horde_Share_Object
$name string The name of the share to retrieve.
return Horde_Share_Object The requested share.

_getShareById() abstract protected method

Returns a Horde_Share_Object object corresponding to the given unique ID, with the details retrieved appropriately.
abstract protected _getShareById ( integer $id ) : Horde_Share_Object_sql
$id integer The id of the share to retrieve.
return Horde_Share_Object_sql The requested share.

_getShares() abstract protected method

Returns an array of Horde_Share_Object objects corresponding to the given set of unique IDs, with the details retrieved appropriately.
abstract protected _getShares ( array $ids ) : array
$ids array The array of ids to retrieve.
return array The requested shares.

_idExists() abstract protected method

Check that a share id exists in the system.
abstract protected _idExists ( integer $id ) : boolean
$id integer The share id
return boolean True if the share exists.

_listAllShares() abstract protected method

Lists *all* shares for the current app/share, regardless of permissions.
abstract protected _listAllShares ( ) : array
return array All shares for the current app/share.

_listShares() abstract protected method

Returns an array of all shares that $userid has access to.
abstract protected _listShares ( string $userid, array $params = [] ) : array
$userid string The userid of the user to check access for.
$params array See listShares().
return array The shares the user has access to.

_newShare() abstract protected method

Returns a new share object.
abstract protected _newShare ( string $name ) : Horde_Share_Object
$name string The share's name.
return Horde_Share_Object A new share object

_removeShare() abstract protected method

Removes a share from the shares system permanently.
abstract protected _removeShare ( Horde_Share_Object $share )
$share Horde_Share_Object The share to remove.

_renameShare() abstract protected method

Renames a share in the shares system.
abstract protected _renameShare ( Horde_Share_Object $share, string $name )
$share Horde_Share_Object The share to rename.
$name string The share's new name.

_sortShares() protected method

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

addCallback() public method

Add a callback to the collection
public addCallback ( string $type, array $callback )
$type string
$callback array

addShare() public method

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

countShares() public method

Returns the number of shares that $userid has access to.
public countShares ( string $userid, integer $perm = Horde_Perms::SHOW, mixed $attributes = null ) : integer
$userid string The userid of the user to check access for.
$perm integer The level of permissions required.
$attributes mixed 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

exists() public method

Checks if a share name exists in the system.
public exists ( string $share ) : boolean
$share string The share name to check.
return boolean True if the share exists.

expireListCache() public method

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

getApp() public method

Returns the application we're managing shares for.
public getApp ( ) : string
return string The application this share belongs to.

getListCache() public method

Returns the share's list cache.
public getListCache ( ) : array
return array

getPermissions() public method

Finds out what rights the given user has to this object.
See also: Horde_Perms::getPermissions
public getPermissions ( mixed $share, string $user = null ) : mixed
$share mixed The share that should be checked for the users permissions.
$user string The user to check for.
return 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.

getPermsObject() public method

Getter for Horde_Perms object
public getPermsObject ( ) : Horde_Perms_Base
return Horde_Perms_Base

getShare() public method

Returns a Horde_Share_Object object corresponding to the given share name, with the details retrieved appropriately.
public getShare ( string $name ) : Horde_Share_Object
$name string The name of the share to retrieve.
return Horde_Share_Object The requested share.

getShareById() public method

Returns a Horde_Share_Object object corresponding to the given unique ID, with the details retrieved appropriately.
public getShareById ( string $cid ) : Horde_Share_Object
$cid string The id of the share to retrieve.
return Horde_Share_Object The requested share.

getShares() public method

Returns an array of Horde_Share_Object objects corresponding to the given set of unique IDs, with the details retrieved appropriately.
public getShares ( array $cids ) : array
$cids array The array of ids to retrieve.
return array The requested shares.

idExists() public method

Check that a share id exists in the system.
public idExists ( integer $id ) : boolean
$id integer The share id
return boolean True if the share exists.

initShareObject() public method

(Re)connects the share object to this share driver.
public initShareObject ( Horde_Share_Object $object )
$object Horde_Share_Object

listAllShares() public method

This is for admin functionality and scripting tools, and shouldn't be called from user-level code!
public listAllShares ( ) : array
return array All shares for the current app/share.

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.

listSystemShares() public method

Returns an array of all system shares.
public listSystemShares ( ) : array
return array All system shares.

newShare() public method

Returns a new share object.
public newShare ( string $owner, string $share_name = '', string $name_attribute = '' ) : Horde_Share_Object
$owner string The share owner name.
$share_name string The share's name.
$name_attribute string The name displayed to the user.
return Horde_Share_Object A new share object.

removeShare() public method

Removes a share from the shares system permanently.
public removeShare ( Horde_Share_Object $share )
$share Horde_Share_Object The share to remove.

renameShare() public method

Renames a share in the shares system.
public renameShare ( Horde_Share_Object $share, string $name )
$share Horde_Share_Object The share to rename.
$name string The share's new name.

resetCache() public method

Resets the internal caches.
public resetCache ( )

runCallback() public method

Give public access to call the share callbacks. Needed to run the callbacks from the Horde_Share_Object objects.
public runCallback ( string $type, array $params ) : mixed
$type string The callback to run
$params array The parameters to pass to the callback.
return mixed

setListCache() public method

Set the list cache.
public setListCache ( array $cache )
$cache array

setLogger() public method

Set a logger object.
public setLogger ( Horde_Log_Logger $logger )
$logger Horde_Log_Logger

setShareCallback() public method

public setShareCallback ( $callback )

setShareClass() public method

Set the class type to use for creating share objects.
public setShareClass ( $classname )

toDriverCharset() public method

Convert TO the storage driver's charset. Individual share objects should implement this method if needed.
public toDriverCharset ( array $data )
$data array Data to be converted.

Property Details

$_app protected property

The application we're managing shares for.
protected string $_app
return string

$_cache protected property

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

$_callbacks protected property

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.
protected array $_callbacks
return array

$_groups protected property

The Horde_Group driver
protected Horde_Group_Base $_groups
return Horde_Group_Base

$_listcache protected property

Cache used for listShares().
protected array $_listcache
return array

$_logger protected property

Logger
protected Horde_Log_Logger $_logger
return Horde_Log_Logger

$_permsObject protected property

The Horde_Perms object
protected Horde_Perms_Base $_permsObject
return Horde_Perms_Base

$_root protected property

The root of the Share tree.
protected mixed $_root
return mixed

$_shareCallback protected property

A callback that is passed to the share objects for setting the objects' Horde_Share object.
protected callback $_shareCallback
return callback

$_shareMap protected property

Id-name-map of already cached share objects.
protected array $_shareMap
return array

$_shareObject protected property

The Horde_Share_Object subclass to instantiate objects as
protected string $_shareObject
return string

$_sortList protected property

A list of objects that we're currently sorting, for reference during the sorting algorithm.
protected array $_sortList
return array

$_user protected property

The current user
protected string $_user
return string