You are here

function subuser_switch_user_access in Subuser 8

Same name and namespace in other branches
  1. 6 subuser.module \subuser_switch_user_access()
  2. 7.2 switch/subuser_switch.module \subuser_switch_user_access()

Check if the user has permission to switch the specified user.

Parameters

$account: The user account to switch to.

Return value

Boolean TRUE if the user has the 'switch to subuser' permission and is attempting to switch to a child user or if the user is returning to their account, otherwise FALSE.

1 call to subuser_switch_user_access()
subuser_switch_user_operations_switch in switch/subuser_switch.module
Callback for subuser switch user operation.
1 string reference to 'subuser_switch_user_access'
subuser_switch_menu in switch/subuser_switch.module
Implements hook_menu().

File

switch/subuser_switch.module, line 71
Provides primary Drupal hook implementations.

Code

function subuser_switch_user_access($account) {
  global $user;
  $children = subuser_load_all($user);
  if (user_access('switch to subuser') && isset($children[$account->uid]) || !empty($_SESSION['subuser_parent']) && $account->uid == $_SESSION['subuser_parent']) {
    return TRUE;
  }
  return FALSE;
}