function subuser_administer_users_access in Subuser 6
Access callback for admin/user/user page.
If user has 'administer users' or 'administer subusers' then allow them to view the administer users page. Filter the view to only the user's they are a parent of if they do not have the 'administer users' permission.
Return value
boolean TRUE access granted, otherwise FALSE.
1 string reference to 'subuser_administer_users_access'
- subuser_menu_alter in ./
subuser.module - Implementation of hook_menu_link_alter().
File
- ./
subuser.module, line 161 - Allows users of a particular role to create sub user account in another role.
Code
function subuser_administer_users_access() {
if (user_access('administer users')) {
return TRUE;
}
if (user_access('administer subusers')) {
global $user;
if (!isset($_SESSION['user_overview_filter'])) {
$_SESSION['user_overview_filter'] = array();
}
// Look for the subuser filter and ensure it is set to the current user if
// found, otherwise it will be added bellow.
$found = FALSE;
foreach ($_SESSION['user_overview_filter'] as $index => $filter) {
list($key, $value) = $filter;
if ($key == 'subuser') {
$_SESSION['user_overview_filter'][$index][1] = $user->uid;
$found = TRUE;
break;
}
}
// Explicitly add the filter.
if (!$found) {
$_SESSION['user_overview_filter'][] = array(
'subuser',
$user->uid,
);
}
return TRUE;
}
return FALSE;
}