You are here

function imagepicker_user_has_role in Image Picker 7

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

Helper function to check if a user has a specific role

4 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
_imagepicker_quota_check in ./imagepicker.functions.inc

File

./imagepicker.functions.inc, line 2926
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

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;
}