You are here

function admin_menu_flush_cache in Administration menu 6.3

Same name and namespace in other branches
  1. 8.3 admin_menu.inc \admin_menu_flush_cache()
  2. 6 admin_menu.inc \admin_menu_flush_cache()
  3. 7.3 admin_menu.inc \admin_menu_flush_cache()

Flush all caches or a specific one.

Parameters

$name: (optional) Name of cache to flush.

1 string reference to 'admin_menu_flush_cache'
admin_menu_menu in ./admin_menu.module
Implements hook_menu().

File

./admin_menu.inc, line 432
Menu builder functions for Administration menu.

Code

function admin_menu_flush_cache($name = NULL) {
  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $_GET['q'])) {
    return MENU_ACCESS_DENIED;
  }
  if (isset($name)) {
    $caches = module_invoke_all('admin_menu_cache_info');
    if (!isset($caches[$name])) {
      return MENU_NOT_FOUND;
    }
  }
  else {
    $caches[$name] = array(
      'title' => t('Every'),
      'callback' => 'drupal_flush_all_caches',
    );
  }

  // Pass the cache to flush forward to the callback.
  $function = $caches[$name]['callback'];
  $function($name);
  drupal_set_message(t('!title cache cleared.', array(
    '!title' => $caches[$name]['title'],
  )));

  // The JavaScript injects a destination request parameter pointing to the
  // originating page, so the user is redirected back to that page. Without
  // destination parameter, the redirect ends on the front page.
  drupal_goto();
}