You are here

function admin_menu_get_hash in Administration menu 7.3

Retrieves a unique hash to be used for client side caching.

Parameters

array $parameters: An array of parameters to use.

Return value

string A unique hash.

2 calls to admin_menu_get_hash()
admin_menu_js_callback_cache_access in ./admin_menu.module
Access callback for the admin_menu "cache" Ajax callback.
admin_menu_page_build in ./admin_menu.module
Implements hook_page_build().

File

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

Code

function admin_menu_get_hash(array $parameters = array()) {

  // A hash should be the same through out a request.
  $hash =& drupal_static(__FUNCTION__);
  if (!isset($hash)) {
    global $language, $user;

    // Determine the parameters to add.
    $parameters += array(
      // Current cache identifier, so clearing caches causes invalidation.
      'css_js_query_string' => variable_get('css_js_query_string', base_convert(REQUEST_TIME, 10, 36)),
      // The current langcode.
      'langcode' => $language->language,
      // The user identifier, roles and current session identifier.
      'session' => session_id(),
      'uid' => $user->uid,
      'roles' => isset($user->roles) ? array_keys($user->roles) : array(),
    );
    drupal_alter(__FUNCTION__, $parameters);

    // Sort the parameters so they're always in the same order.
    ksort($parameters);
    $hash = drupal_hash_base64(serialize($parameters));
  }
  return $hash;
}