FacturaScripts

ControllerPermissions
in package

FinalYes

Manages user permissions for controller access and operations.

Determines what actions a user can perform on a specific page/controller.

Table of Contents

Constants

ADMIN_ACCESS_MODE  = 99
DEFAULT_ACCESS_MODE  = 1

Properties

$accessMode  : int
$allowAccess  : bool
$allowDelete  : bool
$allowExport  : bool
$allowImport  : bool
$allowUpdate  : bool
$onlyOwnerData  : bool

Methods

__construct()  : mixed
set()  : void
Manually set permissions for this controller.
setParams()  : void
Set multiple permission parameters from an associative array.
getUserAccess()  : array<string|int, mixed>
Get user access rules from cache or database.
applyAccessRules()  : void
Apply individual access rules from a RoleAccess object.
buildCacheKey()  : string
Build a cache key for user access permissions.
grantAdminPermissions()  : void
Grant full admin permissions.
hasValidParameters()  : bool
Check if the provided parameters are valid for initialization.
isValidProperty()  : bool
Check if a property exists and is valid for setting.
loadUserPermissions()  : void
Load and apply permissions for a regular user.
setProperty()  : void
Set a property value with appropriate type casting.

Constants

Properties

$accessMode

public int $accessMode = self::DEFAULT_ACCESS_MODE

Access level for the user (1 = basic, 99 = admin)

$onlyOwnerData

public bool $onlyOwnerData = false

Whether the user can only see their own data

Methods

__construct()

public __construct([User|null $user = null ][, string|null $pageName = null ]) : mixed
Parameters
$user : User|null = null
$pageName : string|null = null

set()

Manually set permissions for this controller.

public set(bool $access, int $accessMode, bool $delete, bool $update[, bool $onlyOwner = false ]) : void
Parameters
$access : bool

Whether to allow access

$accessMode : int

The access level

$delete : bool

Whether to allow delete operations

$update : bool

Whether to allow update operations

$onlyOwner : bool = false

Whether to restrict to owner data only

setParams()

Set multiple permission parameters from an associative array.

public setParams(array<string|int, mixed> $params) : void
Parameters
$params : array<string|int, mixed>

Array with permission property names as keys

getUserAccess()

Get user access rules from cache or database.

protected getUserAccess(string $nick, string $pageName) : array<string|int, mixed>
Parameters
$nick : string
$pageName : string
Return values
array<string|int, mixed>

applyAccessRules()

Apply individual access rules from a RoleAccess object.

private applyAccessRules(mixed $access) : void
Parameters
$access : mixed

buildCacheKey()

Build a cache key for user access permissions.

private buildCacheKey(string $nick, string $pageName) : string
Parameters
$nick : string
$pageName : string
Return values
string

grantAdminPermissions()

Grant full admin permissions.

private grantAdminPermissions() : void

hasValidParameters()

Check if the provided parameters are valid for initialization.

private hasValidParameters(User|null $user, string|null $pageName) : bool
Parameters
$user : User|null
$pageName : string|null
Return values
bool

isValidProperty()

Check if a property exists and is valid for setting.

private isValidProperty(string $property) : bool
Parameters
$property : string
Return values
bool

loadUserPermissions()

Load and apply permissions for a regular user.

private loadUserPermissions(string $userNick, string $pageName) : void
Parameters
$userNick : string
$pageName : string

setProperty()

Set a property value with appropriate type casting.

private setProperty(string $property, mixed $value) : void
Parameters
$property : string
$value : mixed

        
On this page

Search results