Constants

VERSION

VERSION

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

$_storage

$_storage : \Horde_Kolab_Storage

The Kolab storage handler

Type

\Horde_Kolab_Storage

$_type

$_type : string

The folder type in the storage backend.

Type

string

$_id_map

$_id_map : array

A map of IDs to folder names.

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, mixed  $parent = null, boolean  $allLevels = true) : integer

Returns the count of all 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.

mixed $parent

The share to start searching from (Horde_Share_Object, share_id, or null)

boolean $allLevels

Return all levels, or just the direct children of $parent?

Throws

\Horde_Share_Exception

Returns

integer —

Number of shares the user has access to.

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.

setStorage()

setStorage(\Horde_Kolab_Storage  $storage) : NULL

Set the Kolab storage backend.

Parameters

\Horde_Kolab_Storage $storage

The Kolab storage handler.

Returns

NULL

getStorage()

getStorage() : \Horde_Kolab_Storage

Return the Kolab storage backend associated with this driver.

Returns

\Horde_Kolab_Storage —

The Kolab storage driver.

getList()

getList() : \Horde_Kolab_Storage_List

Return the Kolab storage folder list handler.

Returns

\Horde_Kolab_Storage_List —

The folder list handler.

getType()

getType() : string

Return the type of folder this share driver will access in the Kolab storage backend (depends on the application calling the share driver).

Returns

string

constructId()

constructId(string  $owner, string  $name, string  $prefix = null) : string

Construct the ID from the owner name and the folder subpath.

Parameters

string $owner

The share owner.

string $name

The name of the folder without the namespace prefix.

string $prefix

The namespace prefix.

Returns

string —

The encoded ID.

constructFolderName()

constructFolderName(string  $owner, string  $subpath, string  $prefix = null) : string

Construct the Kolab storage folder name based on the share name and owner attributes.

Parameters

string $owner

The owner of the share.

string $subpath

The folder subpath.

string $prefix

The namespace prefix.

Returns

string —

The folder name for the Kolab backend.

getFolderNameElements()

getFolderNameElements(string  $folder) : array

Retrieve namespace information for a folder name.

Parameters

string $folder

The folder name.

Returns

array —

A list of namespace prefix, the delimiter and the folder subpath.

getAcl()

getAcl(string  $id) : \An

Retrieve the Kolab specific access rights for a share.

Parameters

string $id

The share ID.

Returns

\An —

array of rights.

setAcl()

setAcl(string  $id, string  $user, string  $acl) : NULL

Set the Kolab specific access rights for a share.

Parameters

string $id

The share ID.

string $user

The user to set the ACL for.

string $acl

The ACL.

Returns

NULL

deleteAcl()

deleteAcl(string  $id, string  $user) : NULL

Delete Kolab specific access rights for a share.

Parameters

string $id

The share ID.

string $user

The user to delete the ACL for

Returns

NULL

save()

save(string  $id, string  $old_id, array  $data) : NULL

Save share data to the storage backend.

Parameters

string $id

The share id.

string $old_id

The old share id.

array $data

The share data.

Returns

NULL

_getShare()

_getShare(string  $name) : \Horde_Share_Object

Returns a Horde_Share_Object_Kolab 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_sql 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(string  $ids) : array

Returns an array of Horde_Share_Object_kolab objects corresponding to the requested folders.

Parameters

string $ids

The ids of the shares to fetch.

Returns

array —

An array of Horde_Share_Object_kolab objects.

_listAllShares()

_listAllShares() : array

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

For the Kolab backend this cannot work in the same way as for the SQL based backend. Permissions are always handled by the backend automatically (IMAP ACLs) and cannot be disabled.

listAllShares() is apparently used during command line scipts where it represents administrator access. This is possible on Kolab by using the "manager" user. In that case a standard listShares() authenticated as "manager" should be sufficient.

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_kolab

Returns a new share object.

Parameters

string $name

The share's name.

Returns

\Horde_Share_Object_kolab —

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::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.

_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

_idEncode()

_idEncode(string  $id) : string

Encode a share ID.

Parameters

string $id

The ID to be encoded.

Returns

string —

The encoded ID.

_idDecode()

_idDecode(string  $id) : string

Decode a share ID.

Parameters

string $id

The ID to be decoded.

Returns

string —

The decoded ID.

_idDeconstruct()

_idDeconstruct(string  $id) : array

Deconstruct the ID elements from the ID string

Parameters

string $id

The ID to be deconstructed.

Returns

array —

A tuple of (owner, folder subpath).

_createObject()

_createObject(string  $id, array  $data = array()) : \Horde_Share_Object

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

Parameters

string $id

The id of the share to retrieve.

array $data

The share data.

Returns

\Horde_Share_Object

The requested share.