class ACLService

Collection of functions for managing User's ACLs.

Methods

static array
aclsForUser(Users $user)

Returns an array containing access control list information. When the $acl instance variable is empty an empty array is returned.

static array
aclToArray(mixed $acls)

Ensures that we are always dealing with an array of ACLs

static bool
addAcl(int $user_id, string $acl)

Add ACL to user's acl field as an element of an array.

static void
checkACL(ACL $acl)

Checks if ACL is found and sets flash message if not the case. Also, checks if it is assigned to a user and sets flash message.

static bool
deleteIfAllowed(int $id)

Deletes ACL if allowed.

static void
manageAcls(array $acls, Users $user, array $newAcls, array $userAcls)

Manages the adding and removing of ACLs.

static bool
removeAcl(int $user_id, string $acl)

Removes ACL from user's acl field array.

static string
setAclAtRegistration()

Sets ACL at registration. If users table is empty the default value is Admin. Otherwise, we set the value to "".

static bool
saveACL(ACL $acl, Input $request)

Saves ACL record.

static void
updateUserACLs(Users $user, array $userAcls, array $acls, array|null $postAcls = null)

Updates user's acl field

static array
unUsedACLs()

Returns array of unused ACLs.

static array
usedACLs()

Returns array of used ACLs.

Details

at line 22
static array aclsForUser(Users $user)

Returns an array containing access control list information. When the $acl instance variable is empty an empty array is returned.

Parameters

Users $user

The user whose ACLs we want to use.

Return Value

array

The array containing access control list information.

at line 33
static array aclToArray(mixed $acls)

Ensures that we are always dealing with an array of ACLs

Parameters

mixed $acls

An array or any type that we want to add to an array.

Return Value

array

An array of acls.

at line 48
static bool addAcl(int $user_id, string $acl)

Add ACL to user's acl field as an element of an array.

Parameters

int $user_id

The id of the user whose acl field we want to modify.

string $acl

The name of the new ACL.

Return Value

bool

True or false depending on success of operation.

at line 67
static void checkACL(ACL $acl)

Checks if ACL is found and sets flash message if not the case. Also, checks if it is assigned to a user and sets flash message.

Parameters

ACL $acl

The ACL to verify.

Return Value

void

at line 85
static bool deleteIfAllowed(int $id)

Deletes ACL if allowed.

Parameters

int $id

The id for the ACL.

Return Value

bool

True if deleted, otherwise false.

at line 109
static void manageAcls(array $acls, Users $user, array $newAcls, array $userAcls)

Manages the adding and removing of ACLs.

Parameters

array $acls

ACLs stored in acl table.

Users $user

The user we want to modify

array $newAcls

The new ACLs for the user.

array $userAcls

The user's existing ACLs.

Return Value

void

at line 127
static bool removeAcl(int $user_id, string $acl)

Removes ACL from user's acl field array.

Parameters

int $user_id

The id of the user whose acl field we want to modify.

string $acl

The name of the ACL to be removed.

Return Value

bool

True if user is found, otherwise we return false.

at line 147
static string setAclAtRegistration()

Sets ACL at registration. If users table is empty the default value is Admin. Otherwise, we set the value to "".

Return Value

string

The value of the ACL we are setting upon registration of a user.

at line 161
static bool saveACL(ACL $acl, Input $request)

Saves ACL record.

Parameters

ACL $acl

The ACL to be Saves

Input $request

The request.

Return Value

bool

True if update is successful, otherwise false.

at line 180
static void updateUserACLs(Users $user, array $userAcls, array $acls, array|null $postAcls = null)

Updates user's acl field

Parameters

Users $user

The user whose ACLs we want to update.

array $userAcls

Existing user's ACLs.

array $acls

All available ACLs.

array|null $postAcls

ACLs from post that are selected.

Return Value

void

at line 191
static array unUsedACLs()

Returns array of unused ACLs.

Return Value

array

$unUsedAcls An array of unused ACLs.

at line 207
static array usedACLs()

Returns array of used ACLs.

Return Value

array

$usedACLs An array of used ACLs.