PHP Класс Vanilla\Permissions

Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( array $permissions = [] ) Permissions constructor.
add ( string $permission, integer | array $IDs ) Add a permission.
compileAndLoad ( array $permissions ) Compile raw permission rows into a formatted array of granted permissions.
getPermissions ( ) : array Grab the current permissions.
has ( string $permission, integer | null $id = null ) : boolean Determine if the permission is present.
hasAll ( array $permissions, integer | null $id = null ) : boolean Determine if all of the provided permissions are present.
hasAny ( array $permissions, integer | null $id = null ) : boolean Determine if any of the provided permissions are present.
isAdmin ( ) : boolean Determine if the admin flag is set.
isBanned ( ) : boolean Determine if the banned flag is set.
merge ( Permissions $source ) Merge in data from another Permissions instance.
overwrite ( string $permission, boolean | array $value ) Set global or replace per-ID permissions.
remove ( $permission, integer | array $IDs ) Remove a permission.
set ( string $permission, boolean $value ) Add a global permission.
setAdmin ( boolean $isAdmin ) Set the admin flag.
setBanned ( boolean $isBanned ) Set the banned flag.
setPermissions ( array $permissions ) Set the permission array.

Описание методов

__construct() публичный Метод

Permissions constructor.
public __construct ( array $permissions = [] )
$permissions array

add() публичный Метод

Add a permission.
public add ( string $permission, integer | array $IDs )
$permission string Permission slug to set the value for (e.g. Vanilla.Discussions.View)
$IDs integer | array One or more IDs of foreign objects (e.g. category IDs)

compileAndLoad() публичный Метод

Compile raw permission rows into a formatted array of granted permissions.
public compileAndLoad ( array $permissions )
$permissions array Rows from the Permissions database table.

getPermissions() публичный Метод

Grab the current permissions.
public getPermissions ( ) : array
Результат array

has() публичный Метод

Determine if the permission is present.
public has ( string $permission, integer | null $id = null ) : boolean
$permission string Permission slug to check the value for (e.g. Vanilla.Discussions.View)
$id integer | null Foreign object ID to validate the permission against (e.g. a category ID)
Результат boolean

hasAll() публичный Метод

Determine if all of the provided permissions are present.
public hasAll ( array $permissions, integer | null $id = null ) : boolean
$permissions array Permission slugs to check the value for (e.g. Vanilla.Discussions.View)
$id integer | null Foreign object ID to validate the permissions against (e.g. a category ID)
Результат boolean

hasAny() публичный Метод

Determine if any of the provided permissions are present.
public hasAny ( array $permissions, integer | null $id = null ) : boolean
$permissions array Permission slugs to check the value for (e.g. Vanilla.Discussions.View)
$id integer | null Foreign object ID to validate the permissions against (e.g. a category ID)
Результат boolean

isAdmin() публичный Метод

Determine if the admin flag is set.
public isAdmin ( ) : boolean
Результат boolean

isBanned() публичный Метод

Determine if the banned flag is set.
public isBanned ( ) : boolean
Результат boolean

merge() публичный Метод

Merge in data from another Permissions instance.
public merge ( Permissions $source )
$source Permissions The source Permissions instance to import permissions from.

overwrite() публичный Метод

Set global or replace per-ID permissions.
public overwrite ( string $permission, boolean | array $value )
$permission string Permission slug to set the value for (e.g. Vanilla.Discussions.View)
$value boolean | array A single value for global permissions or an array of foreign object IDs for per-ID permissions.

remove() публичный Метод

Remove a permission.
public remove ( $permission, integer | array $IDs )
$permission Permission slug to set the value for (e.g. Vanilla.Discussions.View)
$IDs integer | array One or more IDs of foreign objects (e.g. category IDs)

set() публичный Метод

Add a global permission.
public set ( string $permission, boolean $value )
$permission string Permission slug to set the value for (e.g. Vanilla.Discussions.View)
$value boolean Toggle value for the permission: true for granted, false for revoked.

setAdmin() публичный Метод

Set the admin flag.
public setAdmin ( boolean $isAdmin )
$isAdmin boolean Is the user an administrator?

setBanned() публичный Метод

Set the banned flag.
public setBanned ( boolean $isBanned )
$isBanned boolean Is the user banned?

setPermissions() публичный Метод

Set the permission array.
public setPermissions ( array $permissions )
$permissions array A properly-formatted permissions array.