function subuser_access_view_callback in Subuser 8
Same name and namespace in other branches
- 7.2 subuser.module \subuser_access_view_callback()
Our access callback for user viewing - only permits users with 'view subusers' to view user or parent-user to view subusers
Parameters
$account: the account being viewed (user object or uid)
1 call to subuser_access_view_callback()
- subuser_profile2_access in ./
subuser.module - Implements hook_profile2_access().
1 string reference to 'subuser_access_view_callback'
- subuser_menu_alter in ./
subuser.module - Implements hook_menu_alter().
File
- ./
subuser.module, line 126 - Provides primary Drupal hook implementations.
Code
function subuser_access_view_callback($account) {
global $user;
$children = subuser_load_all($user);
$acct_uid = is_object($account) ? $account->uid : $account;
// Never allow access to view the anonymous user account.
if ($acct_uid) {
// Admins can view all, users can view own profiles at all times.
if ($user->uid == $acct_uid || user_access('administer users') || user_access('view subusers', $user) && in_array($acct_uid, $children)) {
return TRUE;
}
elseif (user_access('access user profiles')) {
// At this point, load the complete account object.
if (!is_object($account)) {
$account = user_load((int) $acct_uid);
}
return is_object($account) && $account->access && $account->status;
}
}
return FALSE;
}