function user_access

cis7 user.module user_access($string, $account = NULL)
cle7 user.module user_access($string, $account = NULL)
elmsmedia7 user.module user_access($string, $account = NULL)
icor7 user.module user_access($string, $account = NULL)
meedjum_blog7 user.module user_access($string, $account = NULL)
mooc7 user.module user_access($string, $account = NULL)

Determine whether the user has a given privilege.

Parameters

$string: The permission, such as "administer nodes", being checked for.

$account: (optional) The account to check, if not given use currently logged in user.

Return value

Boolean TRUE if the current user has the requested permission.

All permission checks in Drupal should go through this function. This way, we guarantee consistent behavior, and ensure that the superuser can perform all actions.

472 calls to user_access()
@print_mail_form in sites/all/modules/local_contrib/print/print_mail/print_mail.inc
Menu callback for the send by email form.
@print_mail_settings in sites/all/modules/local_contrib/print/print_mail/print_mail.admin.inc
Menu callback for the send by email module settings form.
accessibility_content_field_attach_view_alter in sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.module
Implements hook_field_attach_view_alter().
accessibility_content_init in sites/all/modules/ulmus/accessibility/modules/accessibility_content/accessibility_content.inc
accessibility_reporting_field_attach_view_alter in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/accessibility_reporting.module
Implements hook_field_attach_view_alter().

... See full list

38 string references to 'user_access'
advanced_help_menu_alter in sites/all/modules/ulmus/advanced_help/advanced_help.module
Implements hook_menu_alter().
context_ui_menu in sites/all/modules/ulmus/context/context_ui/context_ui.module
Implementation of hook_menu().
date_popup_menu in sites/all/modules/ulmus/date/date_popup/date_popup.module
Implements hook_menu().
devel_drupal_goto_alter in sites/all/modules/ulmus/devel/devel.module
Implements hook_drupal_goto_alter().
drupal-6.bare.database.php in modules/simpletest/tests/upgrade/drupal-6.bare.database.php
Bare installation of Drupal 6.17, for test purposes.

... See full list

File

modules/user/user.module, line 794
Enables the user registration and login system.

Code

function user_access($string, $account = NULL) {
  global $user;

  if (!isset($account)) {
    $account = $user;
  }

  // User #1 has all privileges:
  if ($account->uid == 1) {
    return TRUE;
  }

  // To reduce the number of SQL queries, we cache the user's permissions
  // in a static variable.
  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['perm'] = &drupal_static(__FUNCTION__);
  }
  $perm = &$drupal_static_fast['perm'];
  if (!isset($perm[$account->uid])) {
    $role_permissions = user_role_permissions($account->roles);

    $perms = array();
    foreach ($role_permissions as $one_role) {
      $perms += $one_role;
    }
    $perm[$account->uid] = $perms;
  }

  return isset($perm[$account->uid][$string]);
}