function admin_menu_toggle_modules in Administration menu 6.3
Same name and namespace in other branches
- 5.3 admin_menu.module \admin_menu_toggle_modules()
- 5.2 admin_menu.module \admin_menu_toggle_modules()
- 6 admin_menu.inc \admin_menu_toggle_modules()
Menu callback; Enable/disable developer modules.
This can save up to 150ms on each uncached page request.
1 string reference to 'admin_menu_toggle_modules'
- admin_menu_menu in ./
admin_menu.module - Implements hook_menu().
File
- ./
admin_menu.inc, line 349 - Menu builder functions for Administration menu.
Code
function admin_menu_toggle_modules() {
if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], $_GET['q'])) {
return MENU_ACCESS_DENIED;
}
$rebuild = FALSE;
$saved_state = variable_get('admin_menu_devel_modules_enabled', NULL);
if (isset($saved_state)) {
// Re-enable modules that were enabled before.
module_enable($saved_state);
variable_del('admin_menu_devel_modules_enabled');
drupal_set_message(t('Enabled these modules: !module-list.', array(
'!module-list' => implode(', ', $saved_state),
)));
$rebuild = TRUE;
}
else {
// Allow site admins to override this variable via settings.php.
$devel_modules = variable_get('admin_menu_devel_modules', _admin_menu_developer_modules());
// Store currently enabled modules in a variable.
$devel_modules = array_intersect(module_list(FALSE, FALSE), $devel_modules);
$devel_modules = array_diff($devel_modules, variable_get('admin_menu_devel_modules_skip', array()));
if (!empty($devel_modules)) {
variable_set('admin_menu_devel_modules_enabled', $devel_modules);
// Disable developer modules.
module_disable($devel_modules);
drupal_set_message(t('Disabled these modules: !module-list.', array(
'!module-list' => implode(', ', $devel_modules),
)));
$rebuild = TRUE;
}
else {
drupal_set_message(t('No developer modules are enabled.'));
}
}
if ($rebuild) {
// Make sure everything is rebuilt, basically a combination of the calls
// from system_modules() and system_modules_submit().
drupal_rebuild_theme_registry();
menu_rebuild();
cache_clear_all('schema', 'cache');
cache_clear_all();
drupal_clear_css_cache();
drupal_clear_js_cache();
// Synchronize to catch any actions that were added or removed.
actions_synchronize();
// Finally, flush admin_menu's cache.
admin_menu_flush_caches();
}
drupal_goto(referer_uri());
}