RdbAdmin Module

UserPermissionsDb extends BaseModel
in package

User permissions DB.

Tags
since
0.1

Table of Contents

Properties

$cacheKeyPermissionUserRoleId  : string
$cacheKeyPermissionUserRoleIdsData  : string
$cachePath  : string
$cachKeyPermissionModuleData  : string

Methods

add()  : mixed
Add permission data.
checkPermission()  : bool
Check permission for role, user.
delete()  : bool
Delete permission.
deleteCheckPermissionCache()  : mixed
Delete check permission cache.
get()  : mixed
Get a permission data.
listItems()  : array<string|int, mixed>
List permissions saved in DB.
checkPermissionVerifyIdentity()  : array<string|int, mixed>
Verify and get identities.
checkPermissionVerifyRoleHighestPriority()  : bool
Verify that this user's role is highest priority.
getCacheObject()  : CacheInterface
Get cache object.

Properties

$cacheKeyPermissionUserRoleId

protected string $cacheKeyPermissionUserRoleId = 'permissionUser.userRoleID.user_%user_id%'

Cache key for permissions per user role ID. This cache key will be set and delete only in this model.

$cacheKeyPermissionUserRoleIdsData

protected string $cacheKeyPermissionUserRoleIdsData = 'permissionUser.userRoleIDsData.user_%user_id%'

Cache key for permissions per user but can contain many role IDs. This cache key will be set and delete only in this model.

$cachePath

protected string $cachePath = STORAGE_PATH . '/cache/Modules/RdbAdmin/Models/UserPermissionsDb'

Cache folder path.

$cachKeyPermissionModuleData

protected string $cachKeyPermissionModuleData = 'permissionsModuleData.%module_system_name%.%permission_page%'

Cache key for permission module data of certain module and page. This cache key will be set and delete only in this model.

Methods

add()

Add permission data.

public add(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

The associative array where key is column name and value is its value.

Return values
mixed

Return inserted ID if successfully inserted, return 0 (zero), or false if failed to insert.

checkPermission()

Check permission for role, user.

public checkPermission(string $module, string $page, string|array<string|int, mixed> $action[, array<string|int, mixed> $identity = [] ]) : bool
Parameters
$module : string

The module (module system name or folder name) to check.

$page : string

The page name to check.

$action : string|array<string|int, mixed>

The action(s) on that page. Use string if check for single action, use array if check for multiple actions.
If checking for multiple actions, any single action matched with certain module, page will be return true.

$identity : array<string|int, mixed> = []

The associative array of identity. Accepted keys:
'userrole_id' (int|array) check by role.
'user_id' (int) check by user.
Leave blank for auto detect role by default.
In order of default auto detect, it will check for role's permission first but if not found then it will be check for user's permission.

Return values
bool

Return true if permission granted, false for permission denied.

delete()

Delete permission.

public delete(array<string|int, mixed> $where) : bool

Also delete permission cache.

Parameters
$where : array<string|int, mixed>

The condition to delete.

Return values
bool

Return true on success, false for otherwise.

deleteCheckPermissionCache()

Delete check permission cache.

public deleteCheckPermissionCache(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

The associative array. Accepted keys:
'user_id' (int).
Following keys must use together.
'module_system_name' (string).
'permission_page' (string).

get()

Get a permission data.

public get([array<string|int, mixed> $where = [] ]) : mixed
Parameters
$where : array<string|int, mixed> = []

The associative array where key is column name and value is its value.

Return values
mixed

Return object if result was found, return empty, null, false if it was not found.

listItems()

List permissions saved in DB.

public listItems([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed> = []

The associative array options. Available options keys:
search (string) the search term,
where (array) the where conditions where key is column name and value is its value,
sortOrders (array) the sort order where sort key is column name, order key is mysql order (ASC, DESC),
unlimited (bool) set to true to show unlimited items, unset or set to false to show limited items,
limit (int) limit items per page. maximum is 100,
offset (int) offset or start at record. 0 is first record,

Return values
array<string|int, mixed>

Return associative array with total and items in keys.

checkPermissionVerifyIdentity()

Verify and get identities.

protected checkPermissionVerifyIdentity(array<string|int, mixed> $identity, CacheInterface $Cache, int $cacheExpire, string|null &$cacheKeyRolesData) : array<string|int, mixed>

This method's visibility must be protected to let extended class use it.

Parameters
$identity : array<string|int, mixed>

The identity.

$Cache : CacheInterface

The cache object.

$cacheExpire : int

The cache expiration TTL.

$cacheKeyRolesData : string|null

Cache key of roles data. This parameter will be altered for later usage.

Tags
since
1.2.10
see
UserPermissionsDb::checkPermissionPerBuilding()

For reference.

Return values
array<string|int, mixed>

Return verified and get identities.

checkPermissionVerifyRoleHighestPriority()

Verify that this user's role is highest priority.

protected checkPermissionVerifyRoleHighestPriority(array<string|int, mixed> $identity, CacheInterface $Cache, int $cacheExpire, string|null &$cacheKeyRolesData) : bool

This method's visibility must be protected to let extended class use it.

Parameters
$identity : array<string|int, mixed>

The identity.

$Cache : CacheInterface

The cache object.

$cacheExpire : int

The cache expiration TTL.

$cacheKeyRolesData : string|null

Cache key of roles data. This parameter will be altered for later usage.

Tags
since
1.2.10
see
UserPermissionsDb::checkPermissionPerBuilding()

For reference.

Return values
bool

Return true on success, false for otherwise. If return false it must be check with another process but if return true then check permission process should be ended.

getCacheObject()

Get cache object.

protected getCacheObject() : CacheInterface

This method's visibility must be protected to let extended class use it.

Tags
since
1.2.10
Return values
CacheInterface

        
On this page

Search results