PHP 클래스 Habari\ACL

The default Habari ACL class implements groups, and group permissions Users are assigned to one or more groups. Groups are assigned one or more permissions. Membership in any group that grants a permission means you have that permission. Membership in any group that denies that permission denies the user that permission, even if another group grants that permission.
파일 보기 프로젝트 열기: habari/system

공개 메소드들

메소드 설명
__static ( ) Register plugin hooks
_filter_permission_display ( $permission ) : string function _filter_permission_display Filter to localize permission names
_filter_token_description_display ( $token ) : string function _filter_token_description_display Filter to localize token descriptions
_filter_token_group_display ( $group ) : string function _filter_token_group_display Filter to localize token group name
access_check ( Bitmask $bitmask, mixed $access ) : boolean Check a permission bitmask for a particular access type.
access_names ( ) : array Obtain the list of access names (CRUD) to use for permissions.
all_tokens ( string $order = 'id' ) : array Get an array of QueryRecord objects containing all permission tokens
clear_caches ( ) Clears all caches used to hold permissions
create_default_tokens ( ) Creates the default set of permissions.
create_token ( string $name, string $description, string $group, boolean $crud = false ) : mixed Create a new permission token, and save it to the permission tokens table
deny_group ( integer $group_id, mixed $token_id ) : Result Deny permission to a group
deny_user ( integer $user_id, mixed $token_id ) : Result Deny permission to a user
destroy_token ( $token ) : boolean Remove a permission token, and any assignments of it
get_bitmask ( integer $mask ) : Bitmask Get a Bitmask object representing the supplied access integer
get_group_token_access ( integer $group, mixed $token_id ) : an Get the access bitmask of a group for a specific permission token
get_user_token_access ( User | integer $user, string | integer $token ) : Bitmask Return the access bitmask to a specific token for a specific user
grant_group ( integer $group_id, mixed $token_id, string $access = 'full' ) : Result Grant a permission to a group
grant_user ( integer $user_id, integer $token_id, string $access = 'full' ) : Result Grant a permission to a user
group_can ( mixed $group, mixed $token_id, string $access = 'full' ) : boolean Determine whether a group can perform a specific action
group_cannot ( $group, mixed $token_id ) : boolean Determine whether a group is explicitly denied permission to perform a specific action This function does not return true if the group is merely not granted a permission
normalize_token ( string $name ) : string Convert a token name into a valid format
rebuild_permissions ( $user = null ) Reset premissions to their default state
revoke_group_token ( integer $group_id, mixed $token_id ) : the Remove a permission token from the group permissions table
revoke_user_token ( integer $user_id, mixed $token_id ) : the Remove a permission token from the user permissions table
token_description ( mixed $permission ) : string Fetch a permission token's description from the DB
token_exists ( mixed $permission ) : boolean Determine whether a permission token exists
token_id ( string $name ) : integer Get a permission token's ID by its name
token_name ( integer $id ) : string Get a permission token's name by its ID
user_can ( mixed $user, mixed $token_id, string $access = 'full' ) : boolean Determine whether a user can perform a specific action
user_cannot ( mixed $user, mixed $token_id ) : boolean Determine whether a user is explicitly denied permission to perform a specific action This function does not return true if the user is merely not granted a permission
user_tokens ( mixed $user, string $access = 'full', $posts_only = false ) : array Get all the tokens for a given user with a particular kind of access

비공개 메소드들

메소드 설명
cache_tokens ( ) : array Get an associative array of token ids and their name.

메소드 상세

__static() 공개 정적인 메소드

Register plugin hooks
public static __static ( )

_filter_permission_display() 공개 정적인 메소드

function _filter_permission_display Filter to localize permission names
public static _filter_permission_display ( $permission ) : string
리턴 string The localized permission name

_filter_token_description_display() 공개 정적인 메소드

function _filter_token_description_display Filter to localize token descriptions
public static _filter_token_description_display ( $token ) : string
리턴 string The localized token description

_filter_token_group_display() 공개 정적인 메소드

function _filter_token_group_display Filter to localize token group name
public static _filter_token_group_display ( $group ) : string
리턴 string The localized token group name

access_check() 공개 정적인 메소드

Check a permission bitmask for a particular access type.
public static access_check ( Bitmask $bitmask, mixed $access ) : boolean
$bitmask Bitmask The permission bitmask
$access mixed The name of the access to check against (read, write, full)
리턴 boolean Returns true if the given access meets exceeds the access to check against

access_names() 공개 정적인 메소드

Obtain the list of access names (CRUD) to use for permissions.
public static access_names ( ) : array
리턴 array the list of access names available to ACL

all_tokens() 공개 정적인 메소드

Get an array of QueryRecord objects containing all permission tokens
public static all_tokens ( string $order = 'id' ) : array
$order string the order in which to sort the returning array
리턴 array an array of QueryRecord objects containing all tokens

clear_caches() 공개 정적인 메소드

Clears all caches used to hold permissions
public static clear_caches ( )

create_default_tokens() 공개 정적인 메소드

Creates the default set of permissions.
public static create_default_tokens ( )

create_token() 공개 정적인 메소드

Create a new permission token, and save it to the permission tokens table
public static create_token ( string $name, string $description, string $group, boolean $crud = false ) : mixed
$name string The name of the permission
$description string The description of the permission
$group string The token group for organizational purposes
$crud boolean Indicates if the token is a CRUD or boolean type token (default is boolean)
리턴 mixed the ID of the newly created permission, or boolean false

deny_group() 공개 정적인 메소드

Deny permission to a group
public static deny_group ( integer $group_id, mixed $token_id ) : Result
$group_id integer The group ID
$token_id mixed The name or ID of the permission token
리턴 Result of the DB query

deny_user() 공개 정적인 메소드

Deny permission to a user
public static deny_user ( integer $user_id, mixed $token_id ) : Result
$user_id integer The user ID
$token_id mixed The name or ID of the permission token
리턴 Result of the DB query

destroy_token() 공개 정적인 메소드

Remove a permission token, and any assignments of it
public static destroy_token ( $token ) : boolean
리턴 boolean whether the permission was deleted or not

get_bitmask() 공개 정적인 메소드

Get a Bitmask object representing the supplied access integer
public static get_bitmask ( integer $mask ) : Bitmask
$mask integer The access mask, usually stored in the database
리턴 Bitmask An object representing the access value

get_group_token_access() 공개 정적인 메소드

Get the access bitmask of a group for a specific permission token
public static get_group_token_access ( integer $group, mixed $token_id ) : an
$group integer The group ID
$token_id mixed A permission name or ID
리턴 an access bitmask

get_user_token_access() 공개 정적인 메소드

Return the access bitmask to a specific token for a specific user
public static get_user_token_access ( User | integer $user, string | integer $token ) : Bitmask
$user User | integer A User object instance or user id
$token string | integer A permission token name or token ID
리턴 Bitmask An access bitmask

grant_group() 공개 정적인 메소드

Grant a permission to a group
public static grant_group ( integer $group_id, mixed $token_id, string $access = 'full' ) : Result
$group_id integer The group ID
$token_id mixed The name or ID of the permission token to grant
$access string The kind of access to assign the group
리턴 Result of the DB query

grant_user() 공개 정적인 메소드

Grant a permission to a user
public static grant_user ( integer $user_id, integer $token_id, string $access = 'full' ) : Result
$user_id integer The user ID
$token_id integer The name or ID of the permission token to grant
$access string The kind of access to assign the group
리턴 Result of the DB query

group_can() 공개 정적인 메소드

Determine whether a group can perform a specific action
public static group_can ( mixed $group, mixed $token_id, string $access = 'full' ) : boolean
$group mixed A group ID or name
$token_id mixed A permission token ID or name
$access string Check for 'create', 'read', 'update', 'delete', or 'full' access
리턴 boolean Whether the group can perform the action

group_cannot() 공개 정적인 메소드

Determine whether a group is explicitly denied permission to perform a specific action This function does not return true if the group is merely not granted a permission
public static group_cannot ( $group, mixed $token_id ) : boolean
$token_id mixed A permission ID or name
리턴 boolean True if access to the token is denied to the group

normalize_token() 공개 정적인 메소드

Convert a token name into a valid format
public static normalize_token ( string $name ) : string
$name string The name of a permission
리턴 string The permission with spaces converted to underscores and all lowercase

rebuild_permissions() 공개 정적인 메소드

Reset premissions to their default state
public static rebuild_permissions ( $user = null )

revoke_group_token() 공개 정적인 메소드

Remove a permission token from the group permissions table
public static revoke_group_token ( integer $group_id, mixed $token_id ) : the
$group_id integer The group ID
$token_id mixed The name or ID of the permission token
리턴 the result of the DB query

revoke_user_token() 공개 정적인 메소드

Remove a permission token from the user permissions table
public static revoke_user_token ( integer $user_id, mixed $token_id ) : the
$user_id integer The user ID
$token_id mixed The name or ID of the permission token
리턴 the result of the DB query

token_description() 공개 정적인 메소드

Fetch a permission token's description from the DB
public static token_description ( mixed $permission ) : string
$permission mixed a permission name or ID
리턴 string the description of the permission

token_exists() 공개 정적인 메소드

Determine whether a permission token exists
public static token_exists ( mixed $permission ) : boolean
$permission mixed a permission name or ID
리턴 boolean whether the permission exists or not

token_id() 공개 정적인 메소드

Get a permission token's ID by its name
public static token_id ( string $name ) : integer
$name string the name of the permission
리턴 integer the permission's ID

token_name() 공개 정적인 메소드

Get a permission token's name by its ID
public static token_name ( integer $id ) : string
$id integer a token ID
리턴 string the name of the permission, or boolean false

user_can() 공개 정적인 메소드

Determine whether a user can perform a specific action
public static user_can ( mixed $user, mixed $token_id, string $access = 'full' ) : boolean
$user mixed A user object, user ID or a username
$token_id mixed A permission ID or name
$access string Check for 'create', 'read', 'update', 'delete', or 'full' access
리턴 boolean Whether the user can perform the action

user_cannot() 공개 정적인 메소드

Determine whether a user is explicitly denied permission to perform a specific action This function does not return true if the user is merely not granted a permission
public static user_cannot ( mixed $user, mixed $token_id ) : boolean
$user mixed A User object, user ID or a username
$token_id mixed A permission ID or name
리턴 boolean True if access to the token is denied to the user

user_tokens() 공개 정적인 메소드

Get all the tokens for a given user with a particular kind of access
public static user_tokens ( mixed $user, string $access = 'full', $posts_only = false ) : array
$user mixed A user object, user ID or a username
$access string Check for 'create' or 'read', 'update', or 'delete' access
리턴 array of token IDs