PerRecordPerms
in package
Helper for implementing per-record permissions
Table of Contents
Methods
- controllerRestricted() : bool
- Checks to see if per-record permissions apply to a particular controller
- fetchDetails() : array<string|int, mixed>
- Gets the permission details from the database
- getCategoryClause() : string
- Gets a clause to restrict a query to the set of categories the current admin belongs to
- hasRecordPerms() : bool
- Checks if a given controller has at least one permission rule in place
- save() : void
- Save the permissions for a particular record
Methods
controllerRestricted()
Checks to see if per-record permissions apply to a particular controller
public
static controllerRestricted(ManagedAdminController $ctlr) : bool
Parameters
- $ctlr : ManagedAdminController
-
The controller to check
Return values
bool —True if per-record permissions apply
fetchDetails()
Gets the permission details from the database
public
static fetchDetails(ManagedAdminController $ctlr, int $item_id) : array<string|int, mixed>
Parameters
- $ctlr : ManagedAdminController
-
Admin controller for the record in question
- $item_id : int
-
ID of the record
Tags
Return values
array<string|int, mixed> —Contains the following elements: int id array[int]|string categories (ids as int, or the string '*' for all)
getCategoryClause()
Gets a clause to restrict a query to the set of categories the current admin belongs to
public
static getCategoryClause() : string
Return values
string —Example: "(operator_categories = '*' OR operator_categories LIKE '%,123,%')"
hasRecordPerms()
Checks if a given controller has at least one permission rule in place
public
static hasRecordPerms(ManagedAdminController $ctlr) : bool
Parameters
- $ctlr : ManagedAdminController
-
The controller to check
Return values
bool —True if at least one permission rule exists
save()
Save the permissions for a particular record
public
static save(ManagedAdminController $ctlr, int $item_id) : void
Parameters
- $ctlr : ManagedAdminController
-
Admin controller for the record in question
- $item_id : int
-
ID of the record