You are here

function imagepicker_user_has_role in Image Picker 6.2

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_user_has_role()
  2. 7 imagepicker.functions.inc \imagepicker_user_has_role()

Helper function to check if a user has a specific role

5 calls to imagepicker_user_has_role()
imagepicker_admin_images in ./imagepicker.admin.inc
imagepicker_admin_users_list in ./imagepicker.admin.inc
Administration functions
imagepicker_get_public_grouplist in ./imagepicker.functions.inc
for public dropdown
imagepicker_postlet_check_ok in contribs/imagepicker_postlet/imagepicker_postlet.module
_imagepicker_quota_check in ./imagepicker.functions.inc

File

./imagepicker.functions.inc, line 2845
Imagepicker functions

Code

function imagepicker_user_has_role($role, $user = NULL) {
  if ($user == NULL) {
    global $user;
  }

  // first check if $role is numeric or string
  if (is_numeric($role)) {
    if (is_array($user->roles) && in_array($role, array_keys($user->roles))) {
      return TRUE;
    }
  }
  else {
    if (is_array($user->roles) && in_array($role, array_values($user->roles))) {
      return TRUE;
    }
  }
  return FALSE;
}