=== modified file 'includes/menu.inc' --- includes/menu.inc 2009-12-17 13:10:18 +0000 +++ includes/menu.inc 2010-01-02 21:35:52 +0000 @@ -118,6 +118,11 @@ define('MENU_IS_LOCAL_TASK', 0x0080); define('MENU_IS_LOCAL_ACTION', 0x0100); /** + * Internal menu flag -- menu item is a grouping page. + */ +define('MENU_IS_GROUP', 0x0200); + +/** * @} End of "Menu flags". */ @@ -181,6 +186,14 @@ define('MENU_DEFAULT_LOCAL_TASK', MENU_I define('MENU_LOCAL_ACTION', MENU_IS_LOCAL_TASK | MENU_IS_LOCAL_ACTION | MENU_VISIBLE_IN_BREADCRUMB); /** + * Menu type -- a groupping page. + * + * A groupping page is only visible if there are immediate children with the + * same permissions. + */ +define('MENU_GROUP_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB | MENU_IS_GROUP); + +/** * @} End of "Menu item types". */ @@ -2252,6 +2265,19 @@ function menu_rebuild() { list($menu, $masks) = menu_router_build(); _menu_router_save($menu, $masks); _menu_navigation_links_rebuild($menu); + $update = db_update('menu_router'); + $update->fields(array('access callback' => 0)); + $update->condition('type', MENU_GROUP_ITEM); + $update->where('path IN ( + SELECT m.path + FROM menu_router m + INNER JOIN menu_links ml ON ml.router_path = m.path + WHERE NOT EXISTS ( + SELECT * + FROM menu_links ml_child + INNER JOIN menu_router m_child ON ml_child.router_path=m_child.path + WHERE ml_child.plid=ml.mlid AND m.access_callback = m_child.access_callback AND m.access_arguments = m_child.access_arguments))'); + $update->execute(); // Clear the menu, page and block caches. menu_cache_clear_all(); _menu_clear_page_cache();