Index: admin_menu.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.inc,v
retrieving revision 1.47
diff -u -p -r1.47 admin_menu.inc
--- admin_menu.inc	9 Jun 2009 18:21:03 -0000	1.47
+++ admin_menu.inc	11 Jun 2009 15:03:40 -0000
@@ -309,9 +309,8 @@ function admin_menu_admin_menu(&$deleted
  * @return
  *   An array of links that were removed from $menu_links.
  */
-function admin_menu_adjust_items(&$menu_links, &$sort) {
-  global $user;
-  $links = array();
+function admin_menu_adjust_items(&$links, &$sort) {
+  $menu_links = array();
   $deleted = array();
 
   // Change or remove items, or add new top-level items.
@@ -321,57 +320,49 @@ function admin_menu_adjust_items(&$menu_
   unset($menu_links['admin/by-task'], $sort['admin/by-task']);
 
   // Remove certain links to re-position them in admin_menu_admin_menu().
-  foreach ($menu_links as $path => $link) {
+  foreach ($links as $path => $link) {
     // Remove links below
     // - admin/build/node-type/*
     // - node/add*
     if (strpos($path, 'admin/build/node-type/') !== FALSE || strpos($path, 'node/add') !== FALSE) {
       $deleted[$path] = $link;
-      unset($menu_links[$path], $sort[$path]);
+      unset($links[$path], $sort[$path]);
     }
   }
   // Add the icon containing special links.
-  $links[] = array(
+  $links['<front>'] = array(
     'title' => theme('admin_menu_icon'),
-    'path' => '<front>',
     'weight' => -100,
     'parent_path' => '<root>',
     'options' => array('extra class' => 'admin-menu-icon', 'html' => TRUE),
+    'menu_name' => 'admin_menu',
   );
   // Add link to show current authenticated/anonymous users - we will add the
   // data dynamically in the _alter hook.
-  $links[] = array(
+  $links['user'] = array(
     'title' => admin_menu_get_user_count(),
     'description' => t('Current anonymous / authenticated users'),
-    'path' => 'user',
     'weight' => -90,
     'parent_path' => '<root>',
     'options' => array('extra class' => 'admin-menu-action admin-menu-users'),
+    'menu_name' => 'admin_menu',
   );
-  $links[] = array(
+  $links['user/%'] = array(
     'title' => '@username',
-    'path' => 'user/%',
     'weight' => -99,
     'parent_path' => '<root>',
     // Note: @username is dynamically replaced by default, we just invoke
     // replacement by setting the 't' key here.
     'options' => array('extra class' => 'admin-menu-action', 't' => array()),
+    'menu_name' => 'admin_menu',
   );
-  $links[] = array(
+  $links['user/logout'] = array(
     'title' => 'Log out',
-    'path' => 'user/logout',
     'weight' => -100,
     'parent_path' => '<root>',
     'options' => array('extra class' => 'admin-menu-action'),
+    'menu_name' => 'admin_menu',
   );
-  foreach ($links as $item) {
-    $path = $item['path'];
-    $item = admin_menu_link_build($item);
-    $menu_links[$path] = $item;
-    $sort[$path] = 1;
-  }
-
-  return $deleted;
 }
 
 /**
@@ -419,9 +410,9 @@ function admin_menu_theme_settings() {
  */
 function admin_menu_flush_caches() {
   // Flush cached menu tree.
-  db_delete('menu_links')->condition('menu_name', 'admin_menu')->execute();
-  menu_cache_clear('admin_menu');
-  variable_set('admin_menu_rebuild_links', TRUE);
+//  db_delete('menu_links')->condition('menu_name', 'admin_menu')->execute();
+//  menu_cache_clear('admin_menu');
+//  variable_set('admin_menu_rebuild_links', TRUE);
   // Flush cached output of admin_menu.
   cache_clear_all('admin_menu:', 'cache_menu', TRUE);
   // Flush client-side cache hashes.
@@ -547,7 +538,7 @@ function admin_menu_flush_cache($name = 
       break;
 
     case 'menu':
-      module_invoke('menu', 'rebuild');
+      menu_rebuild();
       break;
 
     case 'registry':
@@ -573,6 +564,7 @@ function admin_menu_flush_cache($name = 
         $form = $form_state = array();
         system_clear_cache_submit($form, $form_state);
       }
+      menu_rebuild();
       break;
   }
   drupal_goto();
Index: admin_menu.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.install,v
retrieving revision 1.15
diff -u -p -r1.15 admin_menu.install
--- admin_menu.install	18 Apr 2009 17:24:56 -0000	1.15
+++ admin_menu.install	11 Jun 2009 00:56:12 -0000
@@ -16,6 +16,7 @@ function admin_menu_schema() {
 function admin_menu_install() {
   // Create cache table.
   drupal_install_schema('admin_menu');
+  db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('admin_menu', 'Administration menu', '')");
 }
 
 /**
@@ -83,3 +84,16 @@ function admin_menu_update_7300() {
   db_create_table($ret, 'cache_admin_menu', $schema);
   return $ret;
 }
+
+/**
+ * Add "admin_menu" menu.
+ */
+function admin_menu_update_7301() {
+  $ret = array();
+  if (db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = 'admin_menu'")->fetchField()) {
+    return $ret;
+  }
+  $ret[] = update_sql("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('admin_menu', 'Administration menu', '')");
+  return $ret;
+}
+
Index: admin_menu.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/admin_menu/admin_menu.module,v
retrieving revision 1.73
diff -u -p -r1.73 admin_menu.module
--- admin_menu.module	11 Jun 2009 01:39:20 -0000	1.73
+++ admin_menu.module	11 Jun 2009 15:14:09 -0000
@@ -87,6 +87,50 @@ function admin_menu_menu() {
 }
 
 /**
+ * Implementation of hook_menu_alter().
+ */
+function admin_menu_menu_alter(&$items) {
+  // Move all items below admin/* into administration menu.
+  foreach ($items as $path => $item) {
+    if (strpos($path, 'admin') === 0) {
+      if (strpos($path, 'admin/build/node-type') === 0) {
+        dsm($path);
+        dsm($item);
+      }
+      if (!isset($item['type'])) {
+        $items[$path]['menu_name'] = 'admin_menu';
+      }
+      else {
+        if ($item['type'] & MENU_IS_LOCAL_TASK) {
+          $items[$path]['menu_name'] = 'admin_menu';
+          // Trick this item into the visible menu tree.
+          $items[$path]['_visible'] = TRUE;
+        }
+        if ($item['type'] & MENU_CALLBACK) {
+          #continue;
+        }
+          $items[$path]['menu_name'] = 'admin_menu';
+      }
+    }
+  }
+
+  // Remove 'admin', so children appear on the top-level.
+  $items['admin']['_visible'] = FALSE;
+  // Remove local tasks on 'admin'.
+  $items['admin/by-task']['_visible'] = FALSE;
+  $items['admin/by-module']['_visible'] = FALSE;
+
+//  module_load_include('inc', 'admin_menu');
+//  $sort = array(); // @todo 
+//  admin_menu_adjust_items($items, $sort);
+  #dsm($items);
+}
+
+function admin_menu_copy_items(&$items, $item, $options) {
+  
+}
+
+/**
  * Implementation of hook_init().
  *
  * We can't move this into admin_menu_footer(), because PHP-only based themes
@@ -204,7 +248,7 @@ function admin_menu_footer($main = 0) {
   }
 
   // Check for the flag indicating that we need to rebuild the menu.
-  if ($rebuild) {
+  if (0 && $rebuild) {
     module_load_include('inc', 'admin_menu');
     _admin_menu_rebuild_links();
     variable_del('admin_menu_rebuild_links');
@@ -354,6 +398,10 @@ function admin_menu_tree_output($tree) {
   $output = '';
 
   foreach ($tree as $data) {
+    // Skip dynamic items.
+    if (isset($data['link']['type']) && $data['link']['type'] == MENU_CALLBACK) {
+      continue;
+    }
     $extra_class = isset($data['link']['localized_options']['extra class']) ? $data['link']['localized_options']['extra class'] : NULL;
     $link = admin_menu_item_link($data['link']);
 
@@ -434,13 +482,6 @@ function theme_admin_menu_item($link, $h
 }
 
 /**
- * Implementation of hook_menu_alter().
- */
-function admin_menu_menu_alter() {
-  variable_set('admin_menu_rebuild_links', TRUE);
-}
-
-/**
  * Implementation of hook_translated_menu_link_alter().
  *
  * Here is where we make changes to links that need dynamic information such
