Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.161 diff -u -u -p -r1.161 menu.inc --- includes/menu.inc 13 Apr 2007 08:56:57 -0000 1.161 +++ includes/menu.inc 15 Apr 2007 16:38:52 -0000 @@ -576,7 +576,21 @@ function menu_get_active_help() { function menu_rebuild() { // TODO: split menu and menu links storage. db_query('DELETE FROM {menu}'); - $menu = module_invoke_all('menu'); + + // Get the menu definitions from the modules. + // Don't use module_invoke_all because this is a special case where the + // module name is needed in the resulting array, and it's not worth the + // performance hit to modify module_invoke_all for this one case. + $menu = array(); + foreach (module_implements('menu') as $module) { + $function = $module .'_menu'; + if ($result = $function()) { + foreach (array_keys($result) as $key) { + $result[$key]['module'] = $module; + } + $menu = array_merge($menu, $result); + } + } // Alter the menu as defined in modules, keys are like user/%user. drupal_alter('menu', $menu, MENU_ALTER_MODULE_DEFINED); @@ -813,10 +827,10 @@ function menu_rebuild() { access_callback, access_arguments, page_callback, page_arguments, fit, number_parts, visible, parents, depth, has_children, tab, title, parent, type, mleft, mright, block_callback, description, position, - link_path, attributes, query, fragment, absolute, html) + link_path, attributes, query, fragment, absolute, html, module) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', - '%s', '%s', '%s', '%s', %d, %d)", + '%s', '%s', '%s', '%s', %d, %d, '%s')", $item['_mid'], $item['_pid'], $path, $item['load_functions'], $item['to_arg_functions'], $item['access callback'], serialize($item['access arguments']), $item['page callback'], @@ -827,7 +841,7 @@ function menu_rebuild() { $item['_mright'], $item['block callback'], $item['description'], $item['position'], $link_path, $item['attributes'], $item['query'], $item['fragment'], - $item['absolute'], $item['html']); + $item['absolute'], $item['html'], $item['module']); } } Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.90 diff -u -u -p -r1.90 system.install --- modules/system/system.install 13 Apr 2007 08:53:24 -0000 1.90 +++ modules/system/system.install 15 Apr 2007 16:38:53 -0000 @@ -326,6 +326,7 @@ function system_install() { db_query("CREATE TABLE {menu} ( mid int NOT NULL default 0, pid int NOT NULL default 0, + module varchar(255) NOT NULL, path varchar(255) NOT NULL default '', load_functions varchar(255) NOT NULL default '', to_arg_functions varchar(255) NOT NULL default '', Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.467 diff -u -u -p -r1.467 system.module --- modules/system/system.module 13 Apr 2007 08:56:59 -0000 1.467 +++ modules/system/system.module 15 Apr 2007 16:38:54 -0000 @@ -2345,16 +2345,42 @@ function theme_admin_block_content($cont * Menu callback; prints a listing of admin tasks for each installed module. */ function system_admin_by_module() { - return 'This page awaits rewrite'; // TODO: this needs to be rewritten for the new menu system. $modules = module_rebuild_cache(); + + // Get the admin items with one query, + // and save the mid if the item is accessible + $map = arg(NULL); + $result = db_query("SELECT * FROM {menu} WHERE path LIKE 'admin/%%' AND depth = 2 AND visible = 1 AND path != 'admin/help' ORDER BY mleft"); + while ($item = db_fetch_object($result)) { + _menu_translate($item, $map, MENU_RENDER_LINK); + if ($item->access) { + if (!isset($modules[$item->module]->menu)) { + $modules[$item->module]->menu = array(); + } + $modules[$item->module]->menu[] = $item; + } + } + $menu_items = array(); + $admin_access = user_access('administer access control'); foreach ($modules as $file) { $module = $file->name; if ($module == 'help') { continue; } - $admin_tasks = system_get_module_admin_tasks($module); + $admin_tasks = array(); + + // Check for permissions. + if (module_hook($module, 'perm') && $admin_access) { + $admin_tasks[-1] = l(t('Configure permissions'), 'admin/user/access', array('fragment' => 'module-'. $module)); + } + + if (isset($modules[$module]->menu)) { + foreach ($modules[$module]->menu as $item) { + $admin_tasks[$item->mid] = l($item->title, $item->path); + } + } // Only display a section if there are any available tasks. if (count($admin_tasks)) { @@ -2373,38 +2399,13 @@ function system_admin_by_module() { return theme('system_admin_by_module', $menu_items); } -function system_get_module_admin_tasks($module) { - return array(); // TODO: this needs to be rewritten for the new menu system. - $admin_access = user_access('administer access control'); - $menu = menu_get_menu(); - $admin_tasks = array(); - - // Check for permissions. - if (module_hook($module, 'perm') && $admin_access) { - $admin_tasks[-1] = l(t('Configure permissions'), 'admin/user/access', array('fragment' => 'module-'. $module)); - } - - // Check for menu items that are admin links. - if ($items = module_invoke($module, 'menu', TRUE)) { - foreach ($items as $item) { - $parts = explode('/', $item['path']); - $n = count($parts); - if ((!isset($item['type']) || ($item['type'] & MENU_VISIBLE_IN_TREE)) && ($parts[0] == 'admin') && ($n >= 3) && _menu_item_is_accessible($menu['path index'][$item['path']])) { - $admin_tasks[$item['title']] = l($item['title'], $item['path']); - } - } - } - - return $admin_tasks; -} - /** * Theme output of the dashboard page. */ function theme_system_admin_by_module($menu_items) { - $stripe = 0; - $output = ''; - $container = array(); + $container = array('left' => '', 'right' => ''); + $flip = array('left' => 'right', 'right' => 'left'); + $position = 'left'; // Iterate over all modules foreach ($menu_items as $module => $block) { @@ -2418,9 +2419,10 @@ function theme_system_admin_by_module($m $block['description'] = t($description); if ($block_output = theme('admin_block', $block)) { - if (!$block['position']) { + if (!isset($block['position'])) { // Perform automatic striping. - $block['position'] = ++$stripe % 2 ? 'left' : 'right'; + $block['position'] = $position; + $position = $flip[$position]; } $container[$block['position']] .= $block_output; }