function roleassign_restrict_access in RoleAssign 8
Helper function to restrict access.
Specify whether the current user should be restricted in the roles he/she can assign - as set by the RoleAssign configuration.
Return value
bool Whether or not to restrict the current user.
3 calls to roleassign_restrict_access()
- RoleAssignUserBulkForm::init in src/
Plugin/ views/ field/ RoleAssignUserBulkForm.php - Initialize the plugin.
- roleassign_form_alter in ./
roleassign.module - Implements hook_form_alter().
- roleassign_user_presave in ./
roleassign.module - Implements hook_ENTITY_TYPE_presave() as hook_user_presave().
File
- ./
roleassign.module, line 62 - Allows site administrators to delegate the task of managing user's roles.
Code
function roleassign_restrict_access() {
$restrict_access = TRUE;
// Do nothing if the user already has 'administer permissions' permission.
if (\Drupal::currentUser()
->hasPermission('administer permissions')) {
$restrict_access = FALSE;
}
// Do nothing if the user doesn't have both 'administer users' and
// 'assign roles' permissions.
if (!\Drupal::currentUser()
->hasPermission('administer users') || !\Drupal::currentUser()
->hasPermission('assign roles')) {
$restrict_access = FALSE;
}
return $restrict_access;
}