function admin_menu_form_alter in Administration menu 8.3
Same name and namespace in other branches
- 5.3 admin_menu.inc \admin_menu_form_alter()
- 5 admin_menu.module \admin_menu_form_alter()
- 5.2 admin_menu.module \admin_menu_form_alter()
- 7.3 admin_menu.module \admin_menu_form_alter()
Implements hook_form_alter().
File
- ./
admin_menu.module, line 810 - Render an administrative menu as a dropdown menu at the top of the window.
Code
function admin_menu_form_alter(&$form, &$form_state, $form_id) {
$global_flush_ids = [
'admin_menu_admin_settings_form' => 1,
// Incorporate changed user permissions.
'user_admin_permissions' => 1,
// Removing a role potentially means less permissions.
'user_admin_role_delete_confirm' => 1,
// User name and roles may be changed on the user account form.
'user_profile_form' => 1,
];
if (isset($global_flush_ids[$form_id])) {
$form['#submit'][] = 'admin_menu_form_alter_flush_cache_submit';
// Optionally limit the cache flush to a certain user ID.
$form_state['admin_menu_uid'] = NULL;
if ($form_id == 'user_profile_form') {
// @todo Core: Button-level submit handlers are braindead.
$form['actions']['submit']['#submit'][] = 'admin_menu_form_alter_flush_cache_submit';
$form_state['admin_menu_uid'] = $form_state['entity']->uid;
}
}
// UX: Add a confirmation to the permissions form to ask the user whether to
// auto-enable the 'access administration menu' permission along with
// 'access administration pages'.
if ($form_id == 'user_admin_permissions') {
$form['#attached']['js'][] = drupal_get_path('module', 'admin_menu') . '/admin_menu.admin.js';
}
}