PHP Class Horde_Share_Sql, horde

Inheritance: extends Horde_Share_Base
Mostrar archivo Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_clobFields array Local cache of text/clob fields
$_db Horde_Db_Adapter Handle for the current database connection.
$_nonClobFields array Local cache of non-text/clob fields
$_shareObject string The Horde_Share_Object subclass to instantiate objects as
$_table string Main share table for the current scope.

Public Methods

Method Description
__construct ( $app, $user, Horde_Perms_Base $perms, Horde_Group_Base $groups )
countOwners ( integer $perm = Horde_Perms::SHOW, mixed $parent = null, boolean $allLevels = true ) : integer Count the number of users who have shares with the given permissions for the current user.
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.
getParent ( Horde_Share_Object $child ) : Horde_Share_Object Returns a share's direct parent object.
getShareCriteria ( string $userid, integer $perm = Horde_Perms::SHOW, mixed $attributes = null, mixed $parent = null, boolean $allLevels = true ) : string Returns an array of criteria for querying shares.
getStorage ( ) : Horde_Db_Adapter
getTable ( ) : string Get storage table
listAllShares ( ) : array Lists *all* shares for the current app/share, regardless of permissions.
listOwners ( integer $perm = Horde_Perms::SHOW, mixed $parent = null, boolean $allLevels = true, integer $from, integer $count ) : array Return a list of users who have shares with the given permissions for the current user.
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.
removeShare ( Horde_Share_Object $share ) Removes a share from the shares system permanently.
setStorage ( Horde_Db_Adapter $db )
setTable ( $table ) Set the SQL table name to use for the current scope's share storage.
toDriverCharset ( $data ) Utility function to convert TO the SQL server's charset.

Protected Methods

Method Description
_addShare ( Horde_Share_Object $share ) Adds a share to the shares system.
_buildPermsFromRow ( array $row ) : integer Builds a permission bit mask from the "perm" column.
_convertClobs ( &$data ) Convert clob data to string.
_createObject ( array $data = [] )
_exists ( string $share ) : boolean Checks if a share exists in the system.
_fetchClobFields ( &$shares ) Fetch data for all clob fields of each share passed in $shares.
_fromDriverCharset ( $data ) Utility function to convert from the SQL server's charset.
_getClobFields ( ) : array Return a list of fields in the table that ARE text/clob fields.
_getDistinctClause ( ) : string Return a DISTINCT clause containing all non-clob field names.
_getNonClobFields ( ) : array Return a list of fields in the table that are NOT text/clob fields.
_getShare ( string $name ) : Horde_Share_Object Returns a Horde_Share_Object_sql object corresponding to the given share name, with the details retrieved appropriately.
_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.
_getShareGroups ( array &$share ) Get groups permissions
_getSharePerms ( &$data )
_getShareUsers ( array &$share ) Get users permissions
_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.
_getUserAndGroupCriteria ( string $userid, integer $perm = Horde_Perms::SHOW ) : array Returns criteria statement fragments for querying shares.
_hasGroups ( $share ) Finds out if the share has user set
_hasUsers ( $share ) Finds out if the share has user set
_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.
_loadPermissions ( array &$data ) Helper function to load the permissions data into the share data
_newShare ( string $name ) : Horde_Share_Object Returns a new share object.
_removeShare ( Horde_Share_Object $share ) : boolean Removes a share from the shares system permanently.
_renameShare ( Horde_Share_Object $share, string $name ) Renames a share in the shares system.
_toDriverKeys ( array $data ) : array Convert an array keyed on client keys to an array keyed on the driver keys.

Method Details

__construct() public method

See also: Horde_Share_Base::__construct()
public __construct ( $app, $user, Horde_Perms_Base $perms, Horde_Group_Base $groups )
$perms Horde_Perms_Base
$groups Horde_Group_Base

_addShare() 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.
protected _addShare ( Horde_Share_Object $share )
$share Horde_Share_Object The new share object.

_buildPermsFromRow() protected method

Builds a permission bit mask from the "perm" column.
protected _buildPermsFromRow ( array $row ) : integer
$row array A data row including permission columns.
return integer A permission mask.

_convertClobs() protected method

Convert clob data to string.
protected _convertClobs ( &$data )

_createObject() protected method

protected _createObject ( array $data = [] )
$data array

_exists() protected method

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

_fetchClobFields() protected method

Fetch data for all clob fields of each share passed in $shares.
protected _fetchClobFields ( &$shares )

_fromDriverCharset() protected method

Utility function to convert from the SQL server's charset.
protected _fromDriverCharset ( $data )

_getClobFields() protected method

Return a list of fields in the table that ARE text/clob fields.
protected _getClobFields ( ) : array
return array An array of clob field names.

_getDistinctClause() protected method

Return a DISTINCT clause containing all non-clob field names.
protected _getDistinctClause ( ) : string
return string The DISTINCT clause.

_getNonClobFields() protected method

Return a list of fields in the table that are NOT text/clob fields.
protected _getNonClobFields ( ) : array
return array An array of non-clob field names.

_getShare() protected method

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

_getShareById() protected method

Returns a Horde_Share_Object_sql object corresponding to the given unique ID, with the details retrieved appropriately.
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.

_getShareGroups() protected method

Get groups permissions
protected _getShareGroups ( array &$share )
$share array Share data array

_getSharePerms() protected method

protected _getSharePerms ( &$data )

_getShareUsers() protected method

Get users permissions
protected _getShareUsers ( array &$share )
$share array Share data array

_getShares() protected method

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

_getUserAndGroupCriteria() protected method

Returns criteria statement fragments for querying shares.
protected _getUserAndGroupCriteria ( string $userid, integer $perm = Horde_Perms::SHOW ) : array
$userid string The userid of the user to check access for.
$perm integer The level of permissions required.
return array An array with query and where string fragments.

_hasGroups() protected method

Finds out if the share has user set
protected _hasGroups ( $share )

_hasUsers() protected method

Finds out if the share has user set
protected _hasUsers ( $share )

_idExists() protected method

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

_listAllShares() protected method

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

_listShares() protected method

Returns an array of all shares that $userid has access to.
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.

_loadPermissions() protected method

Helper function to load the permissions data into the share data
protected _loadPermissions ( array &$data )
$data array Array of share attributes

_newShare() protected method

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

_removeShare() protected method

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

_renameShare() protected method

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

_toDriverKeys() protected method

Convert an array keyed on client keys to an array keyed on the driver keys.
protected _toDriverKeys ( array $data ) : array
$data array The client code keyed array.
return array The driver keyed array.

countOwners() public method

Count the number of users who have shares with the given permissions for the current user.
public countOwners ( integer $perm = Horde_Perms::SHOW, mixed $parent = null, boolean $allLevels = true ) : integer
$perm integer The level of permissions required.
$parent mixed The parent share to start looking in. (Horde_Share_Object, share_id, or null).
$allLevels boolean Return all levels, or just the direct children of $parent?
return integer Number of users.

countShares() public method

Returns the count of all shares that $userid has access to.
public countShares ( string $userid, integer $perm = Horde_Perms::SHOW, mixed $attributes = null, mixed $parent = null, boolean $allLevels = true ) : 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.
$parent mixed The share to start searching from (Horde_Share_Object, share_id, or null)
$allLevels boolean Return all levels, or just the direct children of $parent?
return integer Number of shares the user has access to.

getParent() public method

Returns a share's direct parent object.
public getParent ( Horde_Share_Object $child ) : Horde_Share_Object
$child Horde_Share_Object The share to get parent for.
return Horde_Share_Object The parent share, if it exists.

getShareCriteria() public method

Returns an array of criteria for querying shares.
public getShareCriteria ( string $userid, integer $perm = Horde_Perms::SHOW, mixed $attributes = null, mixed $parent = null, boolean $allLevels = true ) : string
$userid string The userid of the user to check access for.
$perm integer The level of permissions required. Set to null to skip permission filtering.
$attributes mixed Restrict the shares returned to those who have these attribute values.
$parent mixed The share to start searching in. (A Horde_Share_Object, share_id or null)
$allLevels boolean Return all levels, or just the direct children of $parent? Defaults to all levels.
return string The criteria string for fetching this user's shares.

getStorage() public method

public getStorage ( ) : Horde_Db_Adapter
return Horde_Db_Adapter

getTable() public method

Get storage table
public getTable ( ) : string
return string

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.

listOwners() public method

Return a list of users who have shares with the given permissions for the current user.
public listOwners ( integer $perm = Horde_Perms::SHOW, mixed $parent = null, boolean $allLevels = true, integer $from, integer $count ) : array
$perm integer The level of permissions required.
$parent mixed The parent share to start looking in. (Horde_Share_Object, share_id, or null)
$allLevels boolean Return all levels, or just the direct children of $parent? Defaults to all levels.
$from integer The user to start listing at.
$count integer The number of users to return.
return array List of users.

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.
 'attribtues'    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.
 'parent'        Start at this share in the hierarchy. Either share_id or
                 Horde_Share_Object
 'all_levels'    List all levels or just the direct children of parent?
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.

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.

setStorage() public method

public setStorage ( Horde_Db_Adapter $db )
$db Horde_Db_Adapter

setTable() public method

Set the SQL table name to use for the current scope's share storage.
public setTable ( $table )

toDriverCharset() public method

Utility function to convert TO the SQL server's charset.
public toDriverCharset ( $data )

Property Details

$_clobFields protected_oe property

Local cache of text/clob fields
protected array $_clobFields
return array

$_db protected_oe property

Handle for the current database connection.
protected Horde_Db_Adapter $_db
return Horde_Db_Adapter

$_nonClobFields protected_oe property

Local cache of non-text/clob fields
protected array $_nonClobFields
return array

$_shareObject protected_oe property

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

$_table protected_oe property

Main share table for the current scope.
protected string $_table
return string