PHP Class RoleModel, vanilla

This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see . Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com
Inheritance: extends Gdn_Model
Afficher le fichier Open project: vanilla/vanilla Class Usage Examples

Méthodes publiques

Свойство Type Description
$RankPermissions A list of permissions that define an increasing ranking of permissions.
$Roles All roles.

Méthodes publiques

Méthode Description
__construct ( ) Class constructor. Defines the related database table name.
cleanUserRoles ( ) Enforce integrity between users and roles.
clearCache ( ) Clear the roles cache.
define ( $Values ) Define a role.
delete ( $where = [], $options = [] )
deleteAndReplace ( integer $roleID, integer $newRoleID ) : boolean Delete a role.
deleteID ( integer $roleID, array $options = [] ) : boolean Delete a role.
filterPersonalInfo ( $Role ) : boolean Use with array_filter to remove PersonalInfo roles.
get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $PageNumber = false ) Returns a resultset of all roles.
getAllDefaultRoles ( ) : array Get the default role IDs for all types of roles.
getApplicantCount ( boolean $Force = false ) : integer Get the current number of applicants waiting to be approved.
getArray ( ) : array Returns an array of RoleID => RoleName pairs.
getAssignable ( ) : array Get the roles that the current user is allowed to assign to another user.
getByName ( array | string $Names, &$Missing = null ) Get a role by name.
getByNotRoleID ( $RoleID ) Returns a resultset of role data NOT related to the specified RoleID.
getByPermission ( $Permission ) Retrieves all roles with the specified permission(s).
getByRoleID ( $RoleID ) Returns a resultset of role data related to the specified RoleID.
getByType ( string $type ) : Gdn_DataSet Return all roles matching a specific type.
getByUserID ( integer $userID ) : Gdn_DataSet Get the roles for a user.
getCategoryPermissions ( integer $roleID ) : array Get the category specific permissions for a role.
getDefaultRoles ( string $type ) : array Get the default role IDs for a type of role.
getDefaultTypes ( boolean $translate = true ) : array Get an array of default role types.
getPermissions ( integer | array $RoleID ) : array Get the permissions for one or more roles.
getPublicUserRoles ( $userID, string $field = "Name" ) : array | null | void Get a list of a user's roles that are permitted to be seen.
getUserCount ( $RoleID, $UsersOnlyWithThisRole = false ) Returns the number of users assigned to the provided RoleID. If $UsersOnlyWithThisRole is TRUE, it will return the number of users who are assigned to this RoleID and NO OTHER.
getWithRankPermissions ( ) : Gdn_DataSet Get all of the roles including their ranking permissions.
roles ( null $RoleID = null, boolean $Force = false ) : array | mixed | null | type
save ( array $FormPostValues, array | false $Settings = false ) : boolean | mixed Save role data.
setUserRoles ( &$Users, string $UserIDColumn = 'UserID', string $RolesColumn = 'Roles' )

Method Details

__construct() public méthode

Class constructor. Defines the related database table name.
public __construct ( )

cleanUserRoles() public static méthode

Enforce integrity between users and roles.
public static cleanUserRoles ( )

clearCache() public méthode

Clear the roles cache.
public clearCache ( )

define() public méthode

Define a role.
public define ( $Values )
$Values

delete() public méthode

public delete ( $where = [], $options = [] )

deleteAndReplace() public méthode

Delete a role.
public deleteAndReplace ( integer $roleID, integer $newRoleID ) : boolean
$roleID integer The ID of the role to delete.
$newRoleID integer Assign users of the deleted role to this new role.
Résultat boolean Returns **true** on success or **false** on failure.

deleteID() public méthode

Delete a role.
public deleteID ( integer $roleID, array $options = [] ) : boolean
$roleID integer The ID of the role to delete.
$options array An array of options to affect the behavior of the delete. - **newRoleID**: The new role to point users to.
Résultat boolean Returns **true** on success or **false** otherwise.

filterPersonalInfo() public static méthode

Use with array_filter to remove PersonalInfo roles.
public static filterPersonalInfo ( $Role ) : boolean
Résultat boolean Whether role is NOT personal info (FALSE = remove it, it's personal).

get() public méthode

Returns a resultset of all roles.
public get ( $OrderFields = '', $OrderDirection = 'asc', $Limit = false, $PageNumber = false )

getAllDefaultRoles() public static méthode

Get the default role IDs for all types of roles.
public static getAllDefaultRoles ( ) : array
Résultat array Returns an array of arrays indexed by role type.

getApplicantCount() public méthode

Get the current number of applicants waiting to be approved.
public getApplicantCount ( boolean $Force = false ) : integer
$Force boolean Whether or not to force a cache refresh.
Résultat integer Returns the number of applicants or 0 if the registration method isn't set to approval.

getArray() public méthode

Returns an array of RoleID => RoleName pairs.
public getArray ( ) : array
Résultat array

getAssignable() public méthode

Get the roles that the current user is allowed to assign to another user.
public getAssignable ( ) : array
Résultat array Returns an array in the format `[RoleID => 'Role Name']`.

getByName() public static méthode

Get a role by name.
public static getByName ( array | string $Names, &$Missing = null )
$Names array | string

getByNotRoleID() public méthode

Returns a resultset of role data NOT related to the specified RoleID.
public getByNotRoleID ( $RoleID )

getByPermission() public méthode

Retrieves all roles with the specified permission(s).
public getByPermission ( $Permission )

getByRoleID() public méthode

Returns a resultset of role data related to the specified RoleID.
public getByRoleID ( $RoleID )

getByType() public méthode

Return all roles matching a specific type.
public getByType ( string $type ) : Gdn_DataSet
$type string Type slug to match role records against.
Résultat Gdn_DataSet

getByUserID() public méthode

Get the roles for a user.
See also: UserModel::getRoles()
public getByUserID ( integer $userID ) : Gdn_DataSet
$userID integer The user to get the roles for.
Résultat Gdn_DataSet Returns the roles as a dataset (with array values).

getCategoryPermissions() public méthode

Get the category specific permissions for a role.
public getCategoryPermissions ( integer $roleID ) : array
$roleID integer The ID of the role to get the permissions for.
Résultat array Returns an array of permissions.

getDefaultRoles() public static méthode

Get the default role IDs for a type of role.
public static getDefaultRoles ( string $type ) : array
$type string One of the {@link RoleModel::TYPE_*} constants.
Résultat array Returns an array of role IDs.

getDefaultTypes() public static méthode

Get an array of default role types.
public static getDefaultTypes ( boolean $translate = true ) : array
$translate boolean Whether or not to translate the type names.
Résultat array Returns an array in the form `[type => name]`.

getPermissions() public méthode

Get the permissions for one or more roles.
public getPermissions ( integer | array $RoleID ) : array
$RoleID integer | array One or more role IDs to get the permissions for.
Résultat array Returns an array of permissions.

getPublicUserRoles() public méthode

Optionally return all the role data or just one field name.
public getPublicUserRoles ( $userID, string $field = "Name" ) : array | null | void
$userID
$field string optionally the field name from the role table to return.
Résultat array | null | void

getUserCount() public méthode

Returns the number of users assigned to the provided RoleID. If $UsersOnlyWithThisRole is TRUE, it will return the number of users who are assigned to this RoleID and NO OTHER.
public getUserCount ( $RoleID, $UsersOnlyWithThisRole = false )

getWithRankPermissions() public méthode

Get all of the roles including their ranking permissions.
public getWithRankPermissions ( ) : Gdn_DataSet
Résultat Gdn_DataSet Returns all of the roles with the ranking permissions.

roles() public static méthode

public static roles ( null $RoleID = null, boolean $Force = false ) : array | mixed | null | type
$RoleID null
$Force boolean
Résultat array | mixed | null | type

save() public méthode

Save role data.
public save ( array $FormPostValues, array | false $Settings = false ) : boolean | mixed
$FormPostValues array The role row to save.
$Settings array | false Not used.
Résultat boolean | mixed Returns the role ID or false on error.

setUserRoles() public static méthode

public static setUserRoles ( &$Users, string $UserIDColumn = 'UserID', string $RolesColumn = 'Roles' )
$Users
$UserIDColumn string
$RolesColumn string

Property Details

$RankPermissions public_oe property

A list of permissions that define an increasing ranking of permissions.
public $RankPermissions

$Roles public_oe static_oe property

All roles.
public static $Roles