\Horde_Perms_Sql

The Horde_Perms_Sql:: class provides a SQL driver for the Horde permissions system.

Copyright 2008-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
getShortName()
newPermission()
getPermission()
getPermissionById()
addPermission()
removePermission()
getPermissions()
getPermissionId()
hasPermission()
exists()
getParents()
getTree()
getParent()
No public properties found
No constants found
_getParents()
$_cache
$_logger
$_params
$_db
$_permsCache
N/A
No private methods found
$_cacheVersion
N/A

Properties

$_cache

$_cache : \Horde_Cache

Cache object.

Type

\Horde_Cache

$_logger

$_logger : \Horde_Log_Logger

Logger.

Type

\Horde_Log_Logger

$_params

$_params : array

Configuration parameters.

Type

array

$_db

$_db : \Horde_Db_Adapter

Handle for the current database connection.

Type

\Horde_Db_Adapter

$_permsCache

$_permsCache : array

Cache of previously retrieved permissions.

Type

array

$_cacheVersion

$_cacheVersion : integer

Incrementing version number if cached classes change.

Type

integer

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Configuration parameters (in addition to base Horde_Perms parameters):

'db' - (Horde_Db_Adapter) [REQUIRED] The DB instance.
'table' - (string) The name of the perms table.
          DEFAULT: 'horde_perms'

Throws

\Horde_Perms_Exception

getShortName()

getShortName(string  $name) : string

Returns the short name of an object, the last portion of the full name.

Parameters

string $name

The name of the object.

Returns

string —

The object's short name.

newPermission()

newPermission(string  $name, string  $type = 'matrix', array  $params = null) : \Horde_Perms_Permission_Sql

Returns a new permissions object.

Parameters

string $name

The permission's name.

string $type

The permission type.

array $params

The permission parameters.

Returns

\Horde_Perms_Permission_Sql

A new permissions object.

getPermission()

getPermission(string  $name) : \Horde_Perms_Permission_Sql

Returns an object corresponding to the named permission, with the users and other data retrieved appropriately.

Parameters

string $name

The name of the permission to retrieve.

Throws

\Horde_Perms_Exception

Returns

\Horde_Perms_Permission_Sql

TODO

getPermissionById()

getPermissionById(integer  $id) : \Horde_Perms_Permission_Sql

Returns a permission object corresponding to the given unique ID, with the users and other data retrieved appropriately.

Parameters

integer $id

The unique ID of the permission to retrieve.

Throws

\Horde_Perms_Exception

Returns

\Horde_Perms_Permission_Sql

TODO

addPermission()

addPermission(\Horde_Perms_Permission_Sql  $perm) : integer

Adds a permission to the permissions system. The permission must first be created with newPermission(), and have any initial users added to it, before this function is called.

Parameters

\Horde_Perms_Permission_Sql $perm

The perm object.

Throws

\Horde_Perms_Exception

Returns

integer —

Permission ID in the database.

removePermission()

removePermission(\Horde_Perms_Permission_Sql  $perm, boolean  $force = false) : boolean

Removes a permission from the permissions system permanently.

Parameters

\Horde_Perms_Permission_Sql $perm

The permission to remove.

boolean $force

Force to remove every child.

Throws

\Horde_Perms_Exception

Returns

boolean —

True if permission was deleted.

getPermissions()

getPermissions(mixed  $permission, string  $user, string  $creator = null) : mixed

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

Parameters

mixed $permission

The full permission name of the object to check the permissions of, or the Horde_Permissions object.

string $user

The user to check for.

string $creator

The user who created the event.

Returns

mixed —

A bitmask of permissions the user has, false if there are none.

getPermissionId()

getPermissionId(\Horde_Perms_Permission  $permission) : integer

Returns the unique identifier of this permission.

Parameters

\Horde_Perms_Permission $permission

The permission object to get the ID of.

Throws

\Horde_Perms_Exception

Returns

integer —

The unique id.

hasPermission()

hasPermission(string  $permission, string  $user, integer  $perm, string  $creator = null) : boolean

Finds out if the user has the specified rights to the given object.

Parameters

string $permission

The permission to check.

string $user

The user to check for.

integer $perm

The permission level that needs to be checked for.

string $creator

The creator of the event

Returns

boolean —

Whether the user has the specified permissions.

exists()

exists(string  $permission) : boolean

Checks if a permission exists in the system.

Parameters

string $permission

The permission to check.

Throws

\Horde_Perms_Exception

Returns

boolean —

True if the permission exists.

getParents()

getParents(string  $child) : array

Returns a list of parent permissions.

Parameters

string $child

The name of the child to retrieve parents for.

Throws

\Horde_Perms_Exception

Returns

array —

A hash with all parents in a tree format.

getTree()

getTree() : array

Returns all permissions of the system in a tree format.

Throws

\Horde_Perms_Exception

Returns

array —

A hash with all permissions in a tree format.

getParent()

getParent(mixed  $child) : integer

Returns a child's direct parent ID.

Parameters

mixed $child

The object name for which to look up the parent's ID.

Throws

\Horde_Perms_Exception

Returns

integer —

The unique ID of the parent.

_getParents()

_getParents(  $parents) 

TODO

Parameters

$parents