Public Member Functions |
| init () |
| getRoles ($includeSuperuser=true, $sort=true) |
| createAuthItem ($name, $type, $description= '', $bizRule=null, $data=null) |
| updateAuthItem ($oldName, $name, $description= '', $bizRule=null, $data=null) |
| getAuthItems ($types=null, $userId=null, CAuthItem $parent=null, $sort=true, $exclude=array()) |
| getAuthItemParents ($item, $type=null, $parentName=null, $direct=false) |
| getAuthItemChildren ($item, $type=null) |
| attachAuthItemBehavior ($items, $userId=null, CAuthItem $parent=null) |
| getSuperusers () |
| attachUserBehavior ($users) |
| isSuperuser ($userId) |
| getPermissions ($itemName=null) |
| hasPermission ($itemName, $parentName=null, $permissions=array()) |
| getAuthManager () |
Detailed Description
Rights authorizer component class file.
- Author
- Christoffer Niska cnisk.nosp@m.a@li.nosp@m.ve.co.nosp@m.m
- Copyright
- Copyright © 2010 Christoffer Niska
- Since
- 0.5
Definition at line 10 of file RAuthorizer.php.
Member Function Documentation
RAuthorizer::attachAuthItemBehavior |
( |
|
$items, |
|
|
|
$userId = null , |
|
|
CAuthItem |
$parent = null |
|
) |
| |
Attaches the rights authorization item behavior to the given item.
- Parameters
-
mixed | $items | the item or items to which attach the behavior. |
int | $userId | the ID of the user to which the item is assigned. |
CAuthItem | $parent | the parent of the given item. |
- Returns
- mixed the item or items with the behavior attached.
Definition at line 292 of file RAuthorizer.php.
RAuthorizer::attachUserBehavior |
( |
|
$users | ) |
|
Attaches the rights user behavior to the given users.
- Parameters
-
mixed | $users | the user or users to which attach the behavior. |
- Returns
- mixed the user or users with the behavior attached.
Definition at line 350 of file RAuthorizer.php.
RAuthorizer::createAuthItem |
( |
|
$name, |
|
|
|
$type, |
|
|
|
$description = '' , |
|
|
|
$bizRule = null , |
|
|
|
$data = null |
|
) |
| |
Creates an authorization item.
- Parameters
-
string | $name | the item name. This must be a unique identifier. |
integer | $type | the item type (0: operation, 1: task, 2: role). |
string | $description | the description for the item. |
string | $bizRule | business rule associated with the item. This is a piece of PHP code that will be executed when checkAccess is called for the item. |
mixed | $data | additional data associated with the item. |
- Returns
- CAuthItem the authorization item
Definition at line 60 of file RAuthorizer.php.
RAuthorizer::excludeInvalidAuthItems |
( |
|
$items, |
|
|
CAuthItem |
$parent = null , |
|
|
|
$exclude = array() |
|
) |
| |
|
protected |
Excludes invalid authorization items. When an item is provided its parents and children are excluded aswell.
- Parameters
-
array | $items | the authorization items to process. |
CAuthItem | $parent | the item to check valid authorization items for. |
array | $exclude | additional items to be excluded. |
- Returns
- array valid authorization items.
Definition at line 164 of file RAuthorizer.php.
RAuthorizer::getAuthItemChildren |
( |
|
$item, |
|
|
|
$type = null |
|
) |
| |
Returns the children for the specified authorization item recursively.
- Parameters
-
mixed | $item | the item for which to get its children. |
integer | $type | the item type (0: operation, 1: task, 2: role). Defaults to null, meaning returning all items regardless of their type. |
- Returns
- array the names of the item's children.
Definition at line 264 of file RAuthorizer.php.
RAuthorizer::getAuthItemParents |
( |
|
$item, |
|
|
|
$type = null , |
|
|
|
$parentName = null , |
|
|
|
$direct = false |
|
) |
| |
Returns the parents of the specified authorization item.
- Parameters
-
mixed | $item | the item name for which to get its parents. |
integer | $type | the item type (0: operation, 1: task, 2: role). Defaults to null, meaning returning all items regardless of their type. |
string | $parentName | the name of the item in which permissions to search. |
boolean | $direct | whether we want the specified items parent or all parents. |
- Returns
- array the names of the parent items.
Definition at line 200 of file RAuthorizer.php.
RAuthorizer::getAuthItemParentsRecursive |
( |
|
$itemName, |
|
|
|
$items, |
|
|
|
$direct |
|
) |
| |
|
private |
Returns the parents of the specified authorization item recursively.
- Parameters
-
string | $itemName | the item name for which to get its parents. |
array | $items | the items to process. |
boolean | $direct | whether we want the specified items parent or all parents. |
- Returns
- the names of the parents items recursively.
Definition at line 231 of file RAuthorizer.php.
RAuthorizer::getAuthItems |
( |
|
$types = null , |
|
|
|
$userId = null , |
|
|
CAuthItem |
$parent = null , |
|
|
|
$sort = true , |
|
|
|
$exclude = array() |
|
) |
| |
Returns the authorization items of the specific type and user.
- Parameters
-
mixed | $types | the item type (0: operation, 1: task, 2: role). Defaults to null, meaning returning all items regardless of their type. |
mixed | $userId | the user ID. Defaults to null, meaning returning all items even if they are not assigned to a user. |
CAuthItem | $parent | the item for which to get the select options. |
boolean | $sort | sort items by to weights. |
array | $exclude | the items to be excluded. |
- Returns
- array the authorization items of the specific type.
Definition at line 109 of file RAuthorizer.php.
RAuthorizer::getAuthManager |
( |
| ) |
|
- Returns
- RAuthManager the authorization manager.
Definition at line 512 of file RAuthorizer.php.
RAuthorizer::getPermissions |
( |
|
$itemName = null | ) |
|
Returns the permissions for a specific authorization item.
- Parameters
-
string | $itemName | the name of the item for which to get permissions. Defaults to null, meaning that the full permission tree is returned. |
- Returns
- the permission tree.
Definition at line 390 of file RAuthorizer.php.
RAuthorizer::getPermissionsRecursive |
( |
CAuthItem |
$item | ) |
|
|
private |
Returns the permissions for a specific authorization item recursively.
- Parameters
-
CAuthItem | $item | the item for which to get permissions. |
- Returns
- array the section of the permissions tree.
Definition at line 413 of file RAuthorizer.php.
RAuthorizer::getRoles |
( |
|
$includeSuperuser = true , |
|
|
|
$sort = true |
|
) |
| |
Returns the a list of all roles.
- Parameters
-
boolean | $includeSuperuser | whether to include the superuser. |
boolean | $sort | whether to sort the items by their weights. |
- Returns
- the roles.
Definition at line 39 of file RAuthorizer.php.
RAuthorizer::getSuperusers |
( |
| ) |
|
Returns the users with superuser privileges.
- Returns
- the superusers.
Definition at line 313 of file RAuthorizer.php.
RAuthorizer::hasPermission |
( |
|
$itemName, |
|
|
|
$parentName = null , |
|
|
|
$permissions = array() |
|
) |
| |
Returns the permission type for an authorization item.
- Parameters
-
string | $itemName | the name of the item to check permission for. |
string | $parentName | the name of the item in which permissions to look. |
array | $permissions | the permissions. |
- Returns
- integer the permission type (0: None, 1: Direct, 2: Inherited).
Definition at line 435 of file RAuthorizer.php.
RAuthorizer::isSuperuser |
( |
|
$userId | ) |
|
Returns whether the user is a superuser.
- Parameters
-
integer | $userId | the id of the user to do the check for. |
- Returns
- boolean whether the user is a superuser.
Definition at line 375 of file RAuthorizer.php.
RAuthorizer::mergeAuthItems |
( |
|
$array1, |
|
|
|
$array2 |
|
) |
| |
|
protected |
Merges two arrays with authorization items preserving the keys.
- Parameters
-
array | $array1 | the items to merge to. |
array | $array2 | the items to merge from. |
- Returns
- array the merged items.
Definition at line 143 of file RAuthorizer.php.
RAuthorizer::sanitizeExpression |
( |
|
$code | ) |
|
|
protected |
Tries to sanitize code to make it safe for execution.
- Parameters
-
string | $code | the code to be execute. |
- Returns
- mixed the return value of eval() or null if the code was unsafe to execute.
Definition at line 467 of file RAuthorizer.php.
RAuthorizer::updateAuthItem |
( |
|
$oldName, |
|
|
|
$name, |
|
|
|
$description = '' , |
|
|
|
$bizRule = null , |
|
|
|
$data = null |
|
) |
| |
Updates an authorization item.
- Parameters
-
string | $oldName | the item name. This must be a unique identifier. |
integer | $name | the item type (0: operation, 1: task, 2: role). |
string | $description | the description for the item. |
string | $bizRule | business rule associated with the item. This is a piece of PHP code that will be executed when checkAccess is called for the item. |
mixed | $data | additional data associated with the item. |
Definition at line 81 of file RAuthorizer.php.
Member Data Documentation
RAuthorizer::$_authManager |
|
private |
RAuthorizer::$superuserName |
The documentation for this class was generated from the following file: