PHP Класс 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
Наследование: extends Gdn_Model
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$RankPermissions A list of permissions that define an increasing ranking of permissions.
$Roles All roles.

Открытые методы

Метод Описание
__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' )

Описание методов

__construct() публичный Метод

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

cleanUserRoles() публичный статический Метод

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

clearCache() публичный Метод

Clear the roles cache.
public clearCache ( )

define() публичный Метод

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

delete() публичный Метод

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

deleteAndReplace() публичный Метод

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.
Результат boolean Returns **true** on success or **false** on failure.

deleteID() публичный Метод

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.
Результат boolean Returns **true** on success or **false** otherwise.

filterPersonalInfo() публичный статический Метод

Use with array_filter to remove PersonalInfo roles.
public static filterPersonalInfo ( $Role ) : boolean
Результат boolean Whether role is NOT personal info (FALSE = remove it, it's personal).

get() публичный Метод

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

getAllDefaultRoles() публичный статический Метод

Get the default role IDs for all types of roles.
public static getAllDefaultRoles ( ) : array
Результат array Returns an array of arrays indexed by role type.

getApplicantCount() публичный Метод

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.
Результат integer Returns the number of applicants or 0 if the registration method isn't set to approval.

getArray() публичный Метод

Returns an array of RoleID => RoleName pairs.
public getArray ( ) : array
Результат array

getAssignable() публичный Метод

Get the roles that the current user is allowed to assign to another user.
public getAssignable ( ) : array
Результат array Returns an array in the format `[RoleID => 'Role Name']`.

getByName() публичный статический Метод

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

getByNotRoleID() публичный Метод

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

getByPermission() публичный Метод

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

getByRoleID() публичный Метод

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

getByType() публичный Метод

Return all roles matching a specific type.
public getByType ( string $type ) : Gdn_DataSet
$type string Type slug to match role records against.
Результат Gdn_DataSet

getByUserID() публичный Метод

Get the roles for a user.
См. также: UserModel::getRoles()
public getByUserID ( integer $userID ) : Gdn_DataSet
$userID integer The user to get the roles for.
Результат Gdn_DataSet Returns the roles as a dataset (with array values).

getCategoryPermissions() публичный Метод

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.
Результат array Returns an array of permissions.

getDefaultRoles() публичный статический Метод

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.
Результат array Returns an array of role IDs.

getDefaultTypes() публичный статический Метод

Get an array of default role types.
public static getDefaultTypes ( boolean $translate = true ) : array
$translate boolean Whether or not to translate the type names.
Результат array Returns an array in the form `[type => name]`.

getPermissions() публичный Метод

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.
Результат array Returns an array of permissions.

getPublicUserRoles() публичный Метод

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.
Результат array | null | void

getUserCount() публичный Метод

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() публичный Метод

Get all of the roles including their ranking permissions.
public getWithRankPermissions ( ) : Gdn_DataSet
Результат Gdn_DataSet Returns all of the roles with the ranking permissions.

roles() публичный статический Метод

public static roles ( null $RoleID = null, boolean $Force = false ) : array | mixed | null | type
$RoleID null
$Force boolean
Результат array | mixed | null | type

save() публичный Метод

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.
Результат boolean | mixed Returns the role ID or false on error.

setUserRoles() публичный статический Метод

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

Описание свойств

$RankPermissions публичное свойство

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

$Roles публичное статическое свойство

All roles.
public static $Roles