PHP Class Airship\Engine\Security\Permissions

Manages user-based and role-based access controls with overlapping pattern-based contexts and a multi-site architecture, with a simple interface. i.e. $this->can('read') // bool(false)
Show file Open project: paragonie/airship

Public Methods

Method Description
__construct ( DBInterface $db )
can ( string $action, string $context_path = '', string $cabin = CABIN_NAME, integer $user_id ) : boolean Perform a permissions check
checkGroup ( string $action, integer $context_id = null, integer $group_id = null, boolean $deep_search = true ) : boolean Do the members of this group have permission to do something?
checkUser ( string $action, integer $context_id = null, integer $user_id = null, boolean $ignore_superuser = false ) : boolean Check that the user, specifically, has permission to do something.
checkUsersGroups ( string $action = '', integer $context_id = null, integer $user_id = null, boolean $ignore_superuser = false ) : boolean Check that any of the users' groups has the permission bit
getOverlap ( string $context = '', string $cabin = CABIN_NAME ) : array Returns an array with overlapping context IDs -- useful for when contexts are used with regular expressions
isSuperUser ( integer $user_id, boolean $ignore_groups = false ) : boolean Is this user a super user? Do they belong in a superuser group?

Method Details

__construct() public method

public __construct ( DBInterface $db )
$db DBInterface

can() public method

Perform a permissions check
public can ( string $action, string $context_path = '', string $cabin = CABIN_NAME, integer $user_id ) : boolean
$action string action label (e.g. 'read')
$context_path string context regex (in perm_contexts)
$cabin string (defaults to current cabin)
$user_id integer (defaults to current user)
return boolean

checkGroup() public method

Do the members of this group have permission to do something?
public checkGroup ( string $action, integer $context_id = null, integer $group_id = null, boolean $deep_search = true ) : boolean
$action string - perm_actions.label
$context_id integer - perm_contexts.contextid
$group_id integer - groups.groupid
$deep_search boolean - Also search groups' inheritances
return boolean

checkUser() public method

Ignores group-based access controls.
public checkUser ( string $action, integer $context_id = null, integer $user_id = null, boolean $ignore_superuser = false ) : boolean
$action string
$context_id integer
$user_id integer
$ignore_superuser boolean
return boolean

checkUsersGroups() public method

Check that any of the users' groups has the permission bit
public checkUsersGroups ( string $action = '', integer $context_id = null, integer $user_id = null, boolean $ignore_superuser = false ) : boolean
$action string
$context_id integer
$user_id integer
$ignore_superuser boolean
return boolean

getOverlap() public method

Returns an array with overlapping context IDs -- useful for when contexts are used with regular expressions
public getOverlap ( string $context = '', string $cabin = CABIN_NAME ) : array
$context string Context
$cabin string Cabin
return array

isSuperUser() public method

Is this user a super user? Do they belong in a superuser group?
public isSuperUser ( integer $user_id, boolean $ignore_groups = false ) : boolean
$user_id integer - User ID
$ignore_groups boolean - Don't look at their groups
return boolean