Class humhub\modules\user\components\PermissionManager

Inheritancehumhub\modules\user\components\PermissionManager » yii\base\Component
Subclasseshumhub\modules\content\components\ContentContainerPermissionManager

Description of PermissionManager

Public Methods

Hide inherited methods

MethodDescriptionDefined By
can() Verifies a given $permission or $permission array for a permission subject. humhub\modules\user\components\PermissionManager
clear() Clears access cache humhub\modules\user\components\PermissionManager
createPermissionArray() Returns Permission Array humhub\modules\user\components\PermissionManager
findUsersByPermission() Returns a query for users which are granted given permission humhub\modules\user\components\PermissionManager
getById() Returns a BasePermission by Id humhub\modules\user\components\PermissionManager
getGroupState() Returns the group permission state of the given group or goups. humhub\modules\user\components\PermissionManager
getPermissions() Returns a list of all Permission objects humhub\modules\user\components\PermissionManager
setGroupState() Sets the state for a given groupId. humhub\modules\user\components\PermissionManager

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createPermissionRecord() Creates a Permission Database record humhub\modules\user\components\PermissionManager
getGroupStateRecord() humhub\modules\user\components\PermissionManager
getModulePermissions() Returns permissions provided by a module humhub\modules\user\components\PermissionManager
getQuery() Creates a Permission Database Query humhub\modules\user\components\PermissionManager
getSubject() Returns the permission subject identity. humhub\modules\user\components\PermissionManager
verify() Verifies a single permission for a given permission subject. humhub\modules\user\components\PermissionManager

Property Details

$_access protected property
protected array $_access = []
$permissions protected property
protected array $permissions null
$subject public property

Method Details

can() public method

Verifies a given $permission or $permission array for a permission subject.

If $params['strict'] is set to true and a $permission array is given all given permissions have to be granted otherwise (default) only one permission test has to pass.

public boolean can ( $permission, $params = [], $allowCaching true )
$permission string|array|humhub\libs\BasePermission
$params array
$allowCaching boolean
throws \yii\base\InvalidConfigException
clear() public method

Clears access cache

public void clear ( )
createPermissionArray() public method

Returns Permission Array

public array createPermissionArray ( $groupId, $returnOnlyChangeable false )
$groupId integer

Id of the group

$returnOnlyChangeable boolean
return array

The permission array

throws \yii\base\Exception
throws \yii\base\InvalidConfigException
createPermissionRecord() protected method

Creates a Permission Database record

protected \yii\db\ActiveRecord createPermissionRecord ( )
findUsersByPermission() public static method (available since version 1.3.8)

Returns a query for users which are granted given permission

public static humhub\modules\user\components\ActiveQueryUser findUsersByPermission ( $permission )
$permission humhub\libs\BasePermission
getById() public method

Returns a BasePermission by Id

public humhub\libs\BasePermission|null getById ( $permissionId, $moduleId )
$permissionId string
$moduleId string
throws \yii\base\InvalidConfigException
getGroupState() public method

Returns the group permission state of the given group or goups.

If the provided $group is an array we check if one of the group states is a BasePermission::STATE_ALLOW and return this state.

public integer getGroupState ( $groups, humhub\libs\BasePermission $permission, $returnDefaultState 1 )
$groups mixed

Either an array of groups or group ids or an single group or goup id

$permission humhub\libs\BasePermission
$returnDefaultState integer
getGroupStateRecord() protected method

protected array|null|\yii\db\ActiveRecord getGroupStateRecord ( $groupId, humhub\libs\BasePermission $permission )
$groupId
$permission humhub\libs\BasePermission
getModulePermissions() protected method

Returns permissions provided by a module

protected array getModulePermissions ( \yii\base\Module $module )
$module \yii\base\Module
return array

Of BasePermissions

throws \yii\base\InvalidConfigException
getPermissions() public method

Returns a list of all Permission objects

public array getPermissions ( )
return array

Of BasePermissions

throws \yii\base\InvalidConfigException
getQuery() protected method

Creates a Permission Database Query

protected \yii\db\ActiveQuery getQuery ( )
getSubject() protected method

Returns the permission subject identity.

If the permission objects $subject property is not set this method returns the currently logged in user identity.

protected humhub\modules\user\models\User getSubject ( )
setGroupState() public method

Sets the state for a given groupId.

public void setGroupState ( $groupId, $permission, $state )
$groupId string
$permission string|humhub\libs\BasePermission

Either permission class or instance

$state string
throws Exception
throws \yii\base\InvalidConfigException
throws \yii\db\StaleObjectException
verify() protected method

Verifies a single permission for a given permission subject.

protected boolean verify ( humhub\libs\BasePermission $permission )
$permission humhub\libs\BasePermission