You are here

function _oauth_common_user_access in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 oauth_common.module \_oauth_common_user_access()
  2. 7.3 oauth_common.module \_oauth_common_user_access()

Access callback function used by several menu items.

Parameters

stdClass $user: A user object.

string $permission: The permission that is needed in addition to edit access on the $user.

1 string reference to '_oauth_common_user_access'
oauth_common_providerui_menu in ./oauth_common_providerui.module
Implementation of hook_menu().

File

./oauth_common.module, line 308

Code

function _oauth_common_user_access($user, $permission = NULL, $token = NULL) {
  $user_permission_access = empty($permission) || user_access($permission);

  // If we have a context check and do not have elevated (any) privs
  if (!$user_permission_access && !is_null($token)) {
    $permission = str_replace('any ', '', $permission) . ' in ' . $token->consumer->context;
    $user_permission_access = user_access($permission);
  }
  return user_edit_access($user) && $user_permission_access;
}