You are here

function admin_menu_js_callback_cache_access in Administration menu 7.3

Access callback for the admin_menu "cache" Ajax callback.

Return value

bool TRUE or FALSE

2 string references to 'admin_menu_js_callback_cache_access'
admin_menu_js_info in ./admin_menu.module
Implements hook_js_info().
admin_menu_menu in ./admin_menu.module
Implements hook_menu().

File

./admin_menu.module, line 427
Render an administrative menu as a dropdown menu at the top of the window.

Code

function admin_menu_js_callback_cache_access() {
  global $user;

  // The user (neither authenticated nor anonymous) has the proper permission.
  if (!user_access('access administration menu')) {
    return FALSE;
  }

  // User is anonymous, return TRUE.
  if (!$user->uid) {
    return TRUE;
  }

  // Retrieve the CSRF token.
  $token = isset($_GET['token']) ? $_GET['token'] : FALSE;

  // User is authenticated, validate the CSRF token.
  return $token && drupal_get_token('admin_menu:' . admin_menu_get_hash()) === $token;
}