Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.509
diff -u -F^f -r1.509 system.module
--- modules/system/system.module	5 Jul 2007 08:48:58 -0000	1.509
+++ modules/system/system.module	15 Jul 2007 03:01:05 -0000
@@ -2678,10 +2678,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 ml.depth >= 2 AND ml.menu_name = 'navigation' AND hidden >= 0
+    ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC");
+  $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;
@@ -2689,57 +2703,44 @@ function system_admin_by_module() {
       continue;
     }
 
-    $admin_tasks = system_get_module_admin_tasks($module);
+    $admin_tasks = array();
+    // Check for permissions.
+    if (module_hook($module, 'perm') && $admin_access) {
+      $admin_tasks[] = l(t('Configure permissions'), 'admin/user/access', array('fragment' => 'module-'. $module));
+    }
+
+    // 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[] = l($items[$path]['title'], $path);
+        }
+      }
+    }
 
     // Only display a section if there are any available tasks.
     if (count($admin_tasks)) {
-
       // Check for help links.
       if (module_invoke($module, 'help', "admin/help#$module", $help_arg)) {
         $admin_tasks[100] = 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) {
@@ -2753,9 +2754,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;
       }
