Index: admin_menu.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.install,v retrieving revision 1.4.2.6.2.5 diff -u -p -r1.4.2.6.2.5 admin_menu.install --- admin_menu.install 17 Jun 2009 10:13:18 -0000 1.4.2.6.2.5 +++ admin_menu.install 11 Jul 2009 19:18:03 -0000 @@ -87,27 +87,23 @@ function admin_menu_update_6300() { } /** - * Add "admin_menu" menu. + * Add the "admin_menu" menu. */ function admin_menu_update_6301() { $ret = array(); + // Delete obsolete variable. variable_del('admin_menu_rebuild_links'); // Create menu. $ret[] = _admin_menu_install_menu(); // Clean-up menu links from earlier versions. db_query("DELETE FROM {menu_links} WHERE module = 'admin_menu' OR menu_name = 'admin_menu'"); - // @todo hook_menu_alter() has no effect on customized menu items. During an - // upgrade from earlier versions, it is possible that users altered - // administrative items. Those will be located at the top-level of the menu - // without this (very crude) reset. Suggestions welcome. - db_query("DELETE FROM {menu_links} WHERE router_path LIKE 'admin%%'"); return $ret; } +/* function admin_menu_form_update_script_selection_form_alter(&$form, $form_state) { if ($form['start']['admin_menu']['#default_value'] <= 6301) { drupal_set_message("BACKUP YOUR DATABASE! Administration menu's upgrade path resets and deletes all custom administrative menu items.", 'error'); } } - -# UPDATE `test_drupal6`.`system` SET `schema_version` = '6300' WHERE `system`.`filename` = 'sites/all/modules/admin_menu/admin_menu.module' LIMIT 1 ; +*/ Index: admin_menu.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v retrieving revision 1.43.2.17.2.15 diff -u -p -r1.43.2.17.2.15 admin_menu.module --- admin_menu.module 4 Jul 2009 13:48:29 -0000 1.43.2.17.2.15 +++ admin_menu.module 11 Jul 2009 19:18:49 -0000 @@ -121,7 +121,7 @@ function admin_menu_menu_alter(&$items) } // Skip invisible MENU_CALLBACKs, but make sure that it is not a // MENU_NORMAL_ITEM, which shares the MENU_VISIBLE_IN_BREADCRUMB bit. - if ($item['type'] == MENU_CALLBACK) { + if ($item['type'] === MENU_CALLBACK) { continue; } $items[$path]['menu_name'] = 'admin_menu'; @@ -130,14 +130,23 @@ function admin_menu_menu_alter(&$items) } // Remove 'admin', so children appear on the top-level. - // @todo If 'admin' gets visible, all children are not re-parented at all. If - // it gets invisible, the menu system still displays it. - $items['admin']['_visible'] = FALSE; + $items['admin']['type'] = MENU_CALLBACK; // Remove local tasks on 'admin'. $items['admin/by-task']['_visible'] = FALSE; $items['admin/by-module']['_visible'] = FALSE; - // Flush client-side caches. + // menu_link_save() looks up the parent's menu_name directly in the database + // instead of taking data in hook_menu() into account. When installing + // admin_menu, {menu_links} contains the default value of 'navigation', which + // is thereby applied to all items, even if this function altered them. There + // is no other way to override this behavior. + // Additionally, if links below admin/ were moved or customized in any way and + // those are moved back into the administration menu, then the menu system + // will not calculate/assign the proper menu link parents when the parent item + // (here: 'admin') is marked as customized. + db_query("UPDATE {menu_links} SET menu_name = 'admin_menu', customized = 0 WHERE router_path = 'admin'"); + + // Flush client-side caches whenever the menu is rebuilt. module_invoke('admin_menu', 'flush_caches'); }