admin_devel.module 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * @file
  4. * Administration and debugging functionality for developers and site builders.
  5. */
  6. /**
  7. * Implements hook_form_FORMID_alter().
  8. */
  9. function admin_devel_form_admin_menu_theme_settings_alter(&$form, &$form_state) {
  10. $form['actions']['wipe_rebuild'] = array(
  11. '#type' => 'submit',
  12. '#value' => t('Rebuild system links'),
  13. '#submit' => array('admin_devel_form_admin_menu_theme_settings_alter_rebuild_submit'),
  14. // @todo Not necessarily ready for mass-consumption yet.
  15. '#access' => FALSE,
  16. );
  17. }
  18. /**
  19. * Form submit handler to wipe and rebuild all 'module' = 'system' menu links.
  20. */
  21. function admin_devel_form_admin_menu_theme_settings_alter_rebuild_submit($form, &$form_state) {
  22. // Delete all auto-generated menu links derived from menu router items.
  23. db_delete('menu_links')
  24. ->condition('module', 'system')
  25. ->execute();
  26. // Rebuild menu links from current menu router items.
  27. menu_rebuild();
  28. drupal_set_message(t('System links derived from menu router paths have been rebuilt.'));
  29. }