Property | Type | Description | |
---|---|---|---|
$DefaultPermissions | Default role permissions. | ||
$RowDefaults | Default row permission values. | ||
$_PermissionColumns | Permission columns. |
Method | Description | |
---|---|---|
__construct ( ) | Class constructor. Defines the related database table name. | |
addDefault ( string $Type, array $Permissions, null | string $Junction = null, null | integer $JunctionId = null ) | Add an entry into the list of default permissions. | |
addPermissions ( array $perms1, array $perms2 ) : array | Add the permissions from one permission array to another. | |
assignDefaults ( boolean $ResetDefaults = false ) | Populate a list of default permissions, per type. | |
cachePermissions ( null $UserID = null, null $RoleID = null ) : array | null | ||
clearPermissions ( ) | Remove the cached permissions for all users. | |
define ( array $PermissionNames, string $Type = 'tinyint', string? $JunctionTable = null, string? $JunctionColumn = null ) | Define one or more permissions with default values. | |
delete ( null $RoleID = null, null $JunctionTable = null, null $JunctionColumn = null, null $JunctionID = null ) | ||
getAllowedPermissionNamespaces ( ) : array | Returns a complete list of all enabled applications & plugins. This list can act as a namespace list for permissions. | |
getDefaults ( ) : array | Grab the list of default permissions by role type | |
getGlobalPermissions ( integer | array $RoleID, string $LimitToSuffix = '' ) : Returns | Get all of the global permissions for one or more roles. | |
getJunctionPermissions ( $Where, null $JunctionTable = null, string $LimitToSuffix = '', array $Options = [] ) : array | ||
getPermissions ( integer | array $RoleID, string $LimitToSuffix = '', boolean $includeJunction = true ) : array | Returns all defined permissions not related to junction tables. Excludes permissions related to applications & plugins that are disabled. | |
getPermissionsByRole ( integer $roleID ) : array | Get the permissions for one or more roles. | |
getPermissionsEdit ( $RoleID, string $LimitToSuffix = '', boolean $includeJunction = true ) : array | ||
getRolePermissions ( integer $RoleID, string $LimitToSuffix = '', string $JunctionTable = false, string $JunctionColumn = false, string $ForeignKey = false, integer $ForeignID = false ) : array | Get the permissions of a role. | |
getRowDefaults ( ) : array | Grab default permission column values. | |
getUserPermissions ( integer $UserID, string $LimitToSuffix = '', string $JunctionTable = false, string $JunctionColumn = false, string $ForeignKey = false, integer $ForeignID = false ) : array | Get the permissions of a user. | |
permissionColumns ( boolean $JunctionTable = false, boolean $JunctionColumn = false ) : mixed | Get all of the permission columns in the system. | |
permissionNamespace ( $PermissionName ) : string | ||
pivotPermissions ( $Data, null $Overrides = null ) : array | ||
resetAllRoles ( string $Type = null ) | Reset permissions for all roles, based on the value in their Type column. | |
resetRole ( integer $RoleId ) | Reset permissions for a role, based on the value in its Type column. | |
sQLPermission ( Gdn_SQLDriver $SQL, mixed $Permissions, string $ForeignAlias, string $ForeignColumn, string $JunctionTable = '', string $JunctionColumn = '' ) | Joins the query to a permission junction table and limits the results accordingly. | |
save ( array $Values, boolean $SaveGlobal = false ) | Save a permission row. | |
saveAll ( $Permissions, null $AllWhere = null ) | ||
splitPermission ( string $PermissionName ) : array | Split a permission name into its constituant parts. | |
stripPermissions ( $Row, $DefaultRow, string $LimitToSuffix = '' ) : mixed | Take a permission row and strip the global/local permissions from it. | |
undefine ( $Names ) | ||
unpivotPermissions ( $Permissions, boolean $IncludeRole = false ) : array |
Method | Description | |
---|---|---|
_Backtick ( $Values ) : array | ||
_MergeDisabledPermissions ( array &$GlobalPermissions ) : void | Merge junction permissions with global permissions if they are disabled. | |
_UnpivotPermissionsRow ( $Row, &$Result, boolean $IncludeRole = false ) | ||
isGlobalPermission ( $Value, $PermissionName, $LimitToSuffix, $Namespaces ) : boolean | Returns whether or not a permission is a global permission. |
protected _MergeDisabledPermissions ( array &$GlobalPermissions ) : void | ||
$GlobalPermissions | array | |
return | void |
protected _UnpivotPermissionsRow ( $Row, &$Result, boolean $IncludeRole = false ) | ||
$Row | ||
$Result | ||
$IncludeRole | boolean |
public __construct ( ) |
public addDefault ( string $Type, array $Permissions, null | string $Junction = null, null | integer $JunctionId = null ) | ||
$Type | string | Type of role the permissions should be added for. |
$Permissions | array | The list of permissions to include. |
$Junction | null | string | Type of junction to base the permission on. |
$JunctionId | null | integer | Identifier for the specific junction record to base the permission on. |
public assignDefaults ( boolean $ResetDefaults = false ) | ||
$ResetDefaults | boolean | If we already have defaults, should they be discarded? |
public clearPermissions ( ) |
public getAllowedPermissionNamespaces ( ) : array | ||
return | array |
public getDefaults ( ) : array | ||
return | array | List of permissions, grouped by role type |
public getPermissionsByRole ( integer $roleID ) : array | ||
$roleID | integer | The role to get the permissions for. |
return | array | Returns a permission array suitable for use in a session. |
public getRolePermissions ( integer $RoleID, string $LimitToSuffix = '', string $JunctionTable = false, string $JunctionColumn = false, string $ForeignKey = false, integer $ForeignID = false ) : array | ||
$RoleID | integer | Unique identifier for role. |
$LimitToSuffix | string | String permission name must match, starting on right (ex: 'View' would match *.*.View) |
$JunctionTable | string | Optionally limit returned permissions to 1 junction (ex: 'Category'). |
$JunctionColumn | string | Column to join junction table on (ex: 'CategoryID'). Required if using $JunctionTable. |
$ForeignKey | string | Foreign table column to join on. |
$ForeignID | integer | Foreign ID to limit join to. |
return | array | Permission records. |
public getRowDefaults ( ) : array | ||
return | array | A list of default permission values. |
public getUserPermissions ( integer $UserID, string $LimitToSuffix = '', string $JunctionTable = false, string $JunctionColumn = false, string $ForeignKey = false, integer $ForeignID = false ) : array | ||
$UserID | integer | Unique identifier for user. |
$LimitToSuffix | string | String permission name must match, starting on right (ex: 'View' would match *.*.View) |
$JunctionTable | string | Optionally limit returned permissions to 1 junction (ex: 'Category'). |
$JunctionColumn | string | Column to join junction table on (ex: 'CategoryID'). Required if using $JunctionTable. |
$ForeignKey | string | Foreign table column to join on. |
$ForeignID | integer | Foreign ID to limit join to. |
return | array | Permission records. |
protected isGlobalPermission ( $Value, $PermissionName, $LimitToSuffix, $Namespaces ) : boolean | ||
$Value | ||
$PermissionName | ||
$LimitToSuffix | ||
$Namespaces | ||
return | boolean |
public static permissionNamespace ( $PermissionName ) : string | ||
$PermissionName | ||
return | string |
public pivotPermissions ( $Data, null $Overrides = null ) : array | ||
$Data | ||
$Overrides | null | |
return | array |
public static resetAllRoles ( string $Type = null ) | ||
$Type | string | Role type to limit the updates to. |
public sQLPermission ( Gdn_SQLDriver $SQL, mixed $Permissions, string $ForeignAlias, string $ForeignColumn, string $JunctionTable = '', string $JunctionColumn = '' ) | ||
$SQL | Gdn_SQLDriver | The SQL driver to add the permission to. |
$Permissions | mixed | The permission name (or array of names) to use when limiting the query. |
$ForeignAlias | string | The alias of the table to join to (ie. Category). |
$ForeignColumn | string | The primary key column name of $JunctionTable (ie. CategoryID). |
$JunctionTable | string | |
$JunctionColumn | string |
public static splitPermission ( string $PermissionName ) : array | ||
$PermissionName | string | The name of the permission. |
return | array | The split permission in the form array(Namespace, Permission,Suffix). |
public stripPermissions ( $Row, $DefaultRow, string $LimitToSuffix = '' ) : mixed | ||
$Row | ||
$DefaultRow | ||
$LimitToSuffix | string | |
return | mixed |
public unpivotPermissions ( $Permissions, boolean $IncludeRole = false ) : array | ||
$Permissions | ||
$IncludeRole | boolean | |
return | array |