You are here

function administerusersbyrole_metadata_user_access in Administer Users by Role 7.2

Access callback for the user entity.

NB the names of variables here are deliberately different from the ones used in the entity module. The reason is to be consistent with the rest of this module. In the entity module:

  • Parameter 2 is named '$entity'. Entity is a user account, which is referred to as $account throughout in this module, so we stick with that.
  • Parameter 3 is named '$account', meaning the account to check as, which is referred to as $check_as in this module.
1 string reference to 'administerusersbyrole_metadata_user_access'
administerusersbyrole_entity_info_alter in ./administerusersbyrole.module
Implements hook_entity_info_alter().

File

./administerusersbyrole.module, line 271
Provides fine-grained permissions for creating, editing, and deleting users.

Code

function administerusersbyrole_metadata_user_access($op, $account = NULL, $check_as = NULL) {

  // Call the base function.
  if (entity_metadata_user_access($op, $account, $check_as)) {
    return TRUE;
  }
  $convert = array(
    'delete' => 'cancel',
    'update' => 'edit',
  );
  if (isset($convert[$op])) {

    // Call our own function.
    $check_as = isset($check_as) ? $check_as : $GLOBALS['user'];
    return _administerusersbyrole_check_access($account, $convert[$op], $check_as);
  }
  return FALSE;
}