Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.513 diff -u -F^f -r1.513 system.module --- modules/system/system.module 2 Aug 2007 20:19:02 -0000 1.513 +++ modules/system/system.module 7 Aug 2007 00:28:52 -0000 @@ -2681,10 +2681,24 @@ 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. + $result = db_query(" + SELECT * + FROM {menu_links} ml + INNER JOIN {menu_router} m ON ml.router_path = m.path + WHERE ml.link_path like 'admin/%' AND ml.link_path != 'admin/help' AND hidden >= 0 AND module = 'system' + "); + $items = array(); + while ($item = db_fetch_array($result)) { + _menu_link_translate($item); + if (!$item['access']) { + continue; + } + $items[$item['path']] = $item; + } $modules = module_rebuild_cache(); $menu_items = array(); $help_arg = drupal_help_arg(); + $admin_access = user_access('administer access control'); foreach ($modules as $file) { $module = $file->name; @@ -2692,57 +2706,44 @@ function system_admin_by_module() { continue; } - $admin_tasks = system_get_module_admin_tasks($module); + $admin_tasks = array(); + $admin_task_count = 0; + // Check for menu items that are admin links. + if ($menu = module_invoke($module, 'menu')) { + foreach (array_keys($menu) as $path) { + if (isset($items[$path])) { + $admin_tasks[$items[$path]['title'] . $admin_task_count ++] = l($items[$path]['title'], $path); + } + } + } // Only display a section if there are any available tasks. if (count($admin_tasks)) { - + // Sort. + ksort($admin_tasks); + // Check for permissions. + if (module_hook($module, 'perm') && $admin_access) { + array_unshift($admin_tasks, l(t('Configure permissions'), 'admin/user/access', array('fragment' => 'module-'. $module))); + } // Check for help links. if (module_invoke($module, 'help', "admin/help#$module", $help_arg)) { - $admin_tasks[100] = l(t('Get help'), "admin/help/$module"); + $admin_tasks[] = l(t('Get help'), "admin/help/$module"); } - - // Sort. - ksort($admin_tasks); - $menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks); } } 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) { @@ -2756,9 +2757,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; }