Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.481 diff -u -u -p -r1.481 system.module --- modules/system/system.module 23 May 2007 08:00:46 -0000 1.481 +++ modules/system/system.module 23 May 2007 12:47:42 -0000 @@ -2524,16 +2524,41 @@ 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 + $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = 'navigation' AND ml.router_path LIKE 'admin/%' AND ml.router_path NOT LIKE 'admin/help%' ORDER BY m.weight, m.title"); + while ($item = db_fetch_object($result)) { + _menu_link_translate($item); + 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->mlid] = l($item->title, $item->path); + } + } // Only display a section if there are any available tasks. if (count($admin_tasks)) { @@ -2552,38 +2577,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) { @@ -2597,9 +2597,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; }