=== removed file 'modules/menu/menu.info'
--- modules/menu/menu.info	2006-11-21 20:55:33 +0000
+++ modules/menu/menu.info	1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-; $Id: menu.info,v 1.3 2006/11/21 20:55:34 dries Exp $
-name = Menu
-description = Allows administrators to customize the site navigation menu.
-package = Core - optional
-version = VERSION

=== modified file 'includes/bootstrap.inc'
--- includes/bootstrap.inc	2006-12-21 22:20:19 +0000
+++ includes/bootstrap.inc	2006-12-30 18:42:00 +0000
@@ -551,7 +551,7 @@ function drupal_page_cache_header($cache
  * Define the critical hooks that force modules to always be loaded.
  */
 function bootstrap_hooks() {
-  return array('init', 'exit');
+  return array('boot', 'exit');
 }
 
 /**
@@ -857,7 +857,7 @@ function _drupal_cache_init($phase) {
       }
       elseif (variable_get('cache', CACHE_DISABLED) == CACHE_NORMAL) {
         require_once './includes/module.inc';
-        bootstrap_invoke_all('init');
+        bootstrap_invoke_all('boot');
         drupal_page_cache_header($cache);
         bootstrap_invoke_all('exit');
         exit();

=== modified file 'includes/common.inc'
--- includes/common.inc	2006-12-21 22:20:19 +0000
+++ includes/common.inc	2006-12-30 18:42:08 +0000
@@ -362,8 +362,8 @@ function drupal_not_found() {
 function drupal_access_denied() {
   drupal_set_header('HTTP/1.1 403 Forbidden');
   watchdog('access denied', check_plain($_GET['q']), WATCHDOG_WARNING);
-
-// Keep old path for reference
+  
+  // Keep old path for reference
   if (!isset($_REQUEST['destination'])) {
     $_REQUEST['destination'] = $_GET['q'];
   }

=== modified file 'includes/menu.inc'
--- includes/menu.inc	2006-12-23 17:27:03 +0000
+++ includes/menu.inc	2006-12-30 17:22:35 +0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: menu.inc,v 1.144 2006/12/23 17:27:03 dries Exp $
+// $Id: menu.inc,v 1.143 2006/12/12 06:02:52 unconed Exp $
 
 /**
  * @file
@@ -172,1221 +172,261 @@ define('MENU_SITE_OFFLINE', 4);
  */
 
 /**
- * Return the menu data structure.
+ * Returns the ancestors (and relevant placeholders) for any given path.
  *
- * The returned structure contains much information that is useful only
- * internally in the menu system. External modules are likely to need only
- * the ['visible'] element of the returned array. All menu items that are
- * accessible to the current user and not hidden will be present here, so
- * modules and themes can use this structure to build their own representations
- * of the menu.
- *
- * $menu['visible'] will contain an associative array, the keys of which
- * are menu IDs. The values of this array are themselves associative arrays,
- * with the following key-value pairs defined:
- * - 'title' - The displayed title of the menu or menu item. It will already
- *   have been translated by the locale system.
- * - 'description' - The description (link title attribute) of the menu item.
- *   It will already have been translated by the locale system.
- * - 'path' - The Drupal path to the menu item. A link to a particular item
- *   can thus be constructed with
- *   l($item['title'], $item['path'], array('title' => $item['description'])).
- * - 'children' - A linear list of the menu ID's of this item's children.
- *
- * Menu ID 0 is the "root" of the menu. The children of this item are the
- * menus themselves (they will have no associated path). Menu ID 1 will
- * always be one of these children; it is the default "Navigation" menu.
- */
-function menu_get_menu() {
-  global $_menu;
-  global $user;
-  global $locale;
-
-  if (!isset($_menu['items'])) {
-    // _menu_build() may indirectly call this function, so prevent infinite loops.
-    $_menu['items'] = array();
-
-    $cid = "$user->uid:$locale";
-    if ($cached = cache_get($cid, 'cache_menu')) {
-      $_menu = unserialize($cached->data);
-    }
-    else {
-      _menu_build();
-      // Cache the menu structure for this user, to expire after one day.
-      cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
-    }
-
-    // Make sure items that cannot be cached are added.
-    _menu_append_contextual_items();
-
-    // Reset the cached $menu in menu_get_item().
-    menu_get_item(NULL, NULL, TRUE);
-  }
-
-  return $_menu;
-}
-
-/**
- * Return the local task tree.
- *
- * Unlike the rest of the menu structure, the local task tree cannot be cached
- * nor determined too early in the page request, because the user's current
- * location may be changed by a menu_set_location() call, and the tasks shown
- * (just as the breadcrumb trail) need to reflect the changed location.
- */
-function menu_get_local_tasks() {
-  global $_menu;
-
-  // Don't cache the local task tree, as it varies by location and tasks are
-  // allowed to be dynamically determined.
-  if (!isset($_menu['local tasks'])) {
-    // _menu_build_local_tasks() may indirectly call this function, so prevent
-    // infinite loops.
-    $_menu['local tasks'] = array();
-    $pid = menu_get_active_nontask_item();
-    if (!_menu_build_local_tasks($pid)) {
-      // If the build returned FALSE, the tasks need not be displayed.
-      $_menu['local tasks'][$pid]['children'] = array();
-    }
-  }
-
-  return $_menu['local tasks'];
-}
-
-/**
- * Retrieves the menu item specified by $mid, or by $path if $mid is not given.
- *
- * @param $mid
- *   The menu ID of the menu item to retrieve.
- * @param $path
- *   The internal path of the menu item to retrieve. Defaults to NULL. Only
- *   used if $mid is not set.
- * @param $reset
- *   Optional flag that resets the static variable cache of the menu tree, if
- *   set to TRUE. Default is FALSE.
- *
- * @return
- *   The menu item found in the site menu, or an empty array if none could be
- *   found.
- */
-function menu_get_item($mid, $path = NULL, $reset = FALSE) {
-  static $menu;
-
-  if (!isset($menu) || $reset) {
-    $menu = menu_get_menu();
-  }
-
-  if (isset($mid)) {
-    return $menu['items'][$mid];
-  }
-
-  if (isset($path)) {
-    return $menu['items'][$menu['path index'][$path]];
-  }
-
-  return array();
-}
-
-/**
- * Retrieves the menu ID and title of all root menus.
+ * For example, the ancestors of node/12345/edit are:
  *
+ * node/12345/edit
+ * node/12345/%
+ * node/%/edit
+ * node/%/%
+ * node/12345
+ * node/%
+ * node
+ *
+ * To generate these, we will use binary numbers where bit 1 represents
+ * original value and bit 0 means wildcard. If the path is node/12/edit/foo
+ * then the 110 bitstring represents node/%/edit where % means that any
+ * argument matches that part.
+ *
+ * @param $parts
+ *   An array of path parts, for the above example
+ *   array('node', '12345', 'edit').
  * @return
- *   Array containing all menus (but not menu items), in the form mid => title.
- */
-function menu_get_root_menus() {
-  $menu = menu_get_menu();
-  $root_menus = array();
-
-  foreach ($menu['items'][0]['children'] as $mid) {
-    $root_menus[$mid] = $menu['items'][$mid]['title'];
-  }
-
-  return $root_menus;
-}
-
-/**
- * Change the current menu location of the user.
- *
- * Frequently, modules may want to make a page or node act as if it were
- * in the menu tree somewhere, even though it was not registered in a
- * hook_menu() implementation. If the administrator has rearranged the menu,
- * the newly set location should respect this in the breadcrumb trail and
- * expanded/collapsed status of menu items in the tree. This function
- * allows this behavior.
- *
- * @param $location
- *   An array specifying a complete or partial breadcrumb trail for the
- *   new location, in the same format as the return value of hook_menu().
- *   The last element of this array should be the new location itself.
- *
- * This function will set the new breadcrumb trail to the passed-in value,
- * but if any elements of this trail are visible in the site tree, the
- * trail will be "spliced in" to the existing site navigation at that point.
+ *  An array which contains the ancestors and placeholders. Placeholders
+ *  simply contain as many %s as the ancestors. 
  */
-function menu_set_location($location) {
-  global $_menu;
-  $temp_id = min(array_keys($_menu['items'])) - 1;
-  $prev_id = 0;
-
-  // Don't allow this function to change the actual current path, just the
-  // position in the menu tree.
-  $location[count($location) - 1]['path'] = $_GET['q'];
-
-  foreach (array_reverse($location) as $item) {
-    if (isset($_menu['path index'][$item['path']])) {
-      $mid = $_menu['path index'][$item['path']];
-      if (isset($_menu['visible'][$mid])) {
-        // Splice in the breadcrumb at this location.
-        if ($prev_id) {
-          $_menu['items'][$prev_id]['pid'] = $mid;
-        }
-        $prev_id = 0;
-        break;
+function menu_get_ancestors($parts) {
+  $n1 = count($parts);
+  $placeholders = array();
+  $ancestors = array();
+  $end = (1 << $n1) - 1;
+  $length = $n1 - 1;
+  for ($i = $end; $i > 0; $i--) {
+    $current = '';
+    $count = 0;
+    for ($j = $length; $j >= 0; $j--) {
+      if ($i & (1 << $j)) {
+        $count++;
+        $current .= $parts[$length - $j];
       }
       else {
-        // A hidden item; show it, but only temporarily.
-        $_menu['items'][$mid]['type'] |= MENU_VISIBLE_IN_BREADCRUMB;
-        if ($prev_id) {
-          $_menu['items'][$prev_id]['pid'] = $mid;
-        }
-        $prev_id = $mid;
+        $current .= '%';
       }
-    }
-    else {
-      $item['type'] |= MENU_VISIBLE_IN_BREADCRUMB;
-      if ($prev_id) {
-        $_menu['items'][$prev_id]['pid'] = $temp_id;
+      if ($j) {
+        $current .= '/';
       }
-      $_menu['items'][$temp_id] = $item;
-      $_menu['path index'][$item['path']] = $temp_id;
-
-      $prev_id = $temp_id;
-      $temp_id--;
-    }
-  }
-
-  if ($prev_id) {
-    // Didn't find a home, so attach this to the main navigation menu.
-    $_menu['items'][$prev_id]['pid'] = 1;
-  }
-
-  $final_item = array_pop($location);
-  menu_set_active_item($final_item['path']);
-}
-
-/**
- * Execute the handler associated with the active menu item.
- *
- * This is called early in the page request. The active menu item is at
- * this point determined exclusively by the URL. The handler that is called
- * here may, as a side effect, change the active menu item so that later
- * menu functions (that display the menus and breadcrumbs, for example)
- * act as if the user were in a different location on the site.
- */
-function menu_execute_active_handler() {
-  if (_menu_site_is_offline()) {
-    return MENU_SITE_OFFLINE;
-  }
-
-  $menu = menu_get_menu();
-
-  // Determine the menu item containing the callback.
-  $path = $_GET['q'];
-  while ($path && !isset($menu['callbacks'][$path])) {
-    $path = substr($path, 0, strrpos($path, '/'));
-  }
-
-  if (!isset($menu['callbacks'][$path])) {
-    return MENU_NOT_FOUND;
-  }
-
-  if (!function_exists($menu['callbacks'][$path]['callback'])) {
-    return MENU_NOT_FOUND;
-  }
-
-  if (!_menu_item_is_accessible(menu_get_active_item())) {
-    return MENU_ACCESS_DENIED;
-  }
-
-  // We found one, and are allowed to execute it.
-  $arguments = isset($menu['callbacks'][$path]['callback arguments']) ? $menu['callbacks'][$path]['callback arguments'] : array();
-  $arg = substr($_GET['q'], strlen($path) + 1);
-  if (strlen($arg)) {
-    $arguments = array_merge($arguments, explode('/', $arg));
-  }
-
-  return call_user_func_array($menu['callbacks'][$path]['callback'], $arguments);
-}
-
-/**
- * Returns the ID of the active menu item.
- */
-function menu_get_active_item() {
-  return menu_set_active_item();
-}
-
-/**
- * Sets the path of the active menu item.
- */
-function menu_set_active_item($path = NULL) {
-  static $stored_mid;
-
-  if (!isset($stored_mid) || isset($path)) {
-    if (!isset($path)) {
-      $path = $_GET['q'];
-    }
-    else {
-      $_GET['q'] = $path;
     }
-    $menu = menu_get_menu();
-
-    while ($path && !isset($menu['path index'][$path])) {
-      $path = substr($path, 0, strrpos($path, '/'));
+    // If the number was like 10...0 then the next number will be 11...11,
+    // one bit less wide.
+    if ($count == 1) {
+      $length--;
     }
-    $stored_mid = isset($menu['path index'][$path]) ? $menu['path index'][$path] : 0;
-
-    // Search for default local tasks to activate instead of this item.
-    $continue = TRUE;
-    while ($continue) {
-      $continue = FALSE;
-      if (isset($menu['items'][$stored_mid]['children'])) {
-        foreach ($menu['items'][$stored_mid]['children'] as $cid) {
-          if ($menu['items'][$cid]['type'] & MENU_LINKS_TO_PARENT) {
-            $stored_mid = $cid;
-            $continue = TRUE;
-          }
-        }
-      }
-    }
-
-    // Reset the cached $menu in menu_get_item().
-    menu_get_item(NULL, NULL, TRUE);
+    $placeholders[] = "'%s'";
+    $ancestors[] = $current;
   }
-
-  return $stored_mid;
+  return array($ancestors, $placeholders);
 }
 
 /**
- * Returns the ID of the current menu item or, if the current item is a
- * local task, the menu item to which this task is attached.
- */
-function menu_get_active_nontask_item() {
-  $mid = menu_get_active_item();
-
-  // Find the first non-task item:
-  while ($mid) {
-    $item = menu_get_item($mid);
-
-    if (!($item['type'] & MENU_IS_LOCAL_TASK)) {
-      return $mid;
-    }
-
-    $mid = $item['pid'];
-  }
-}
-
-/**
- * Returns the title of the active menu item.
- */
-function menu_get_active_title() {
-  if ($mid = menu_get_active_nontask_item()) {
-    $item = menu_get_item($mid);
-    return $item['title'];
-  }
-}
-
-/**
- * Returns the help associated with the active menu item.
- */
-function menu_get_active_help() {
-  $path = $_GET['q'];
-  $output = '';
-
-  if (!_menu_item_is_accessible(menu_get_active_item())) {
-    // Don't return help text for areas the user cannot access.
-    return;
-  }
-
-  foreach (module_list() as $name) {
-    if (module_hook($name, 'help')) {
-      if ($temp = module_invoke($name, 'help', $path)) {
-        $output .= $temp . "\n";
-      }
-      if (module_hook('help', 'page')) {
-        if (arg(0) == "admin") {
-          if (module_invoke($name, 'help', 'admin/help#'. arg(2)) && !empty($output)) {
-            $output .= theme("more_help_link", url('admin/help/'. arg(2)));
-          }
-        }
-      }
-    }
-  }
-  return $output;
-}
-
-/**
- * Returns an array of rendered menu items in the active breadcrumb trail.
- */
-function menu_get_active_breadcrumb() {
-
-  // No breadcrumb for the front page.
-  if (drupal_is_front_page()) {
-    return array();
-  }
-
-  // We do *not* want to use "variable_get('site_frontpage', 'node)" here
-  // as that will create the link '/node'. This is unsightly and creates
-  // a second URL for the homepage ('/' *and* '/node').
-  $links[] = l(t('Home'), '');
-
-  $trail = _menu_get_active_trail();
-  foreach ($trail as $mid) {
-    $item = menu_get_item($mid);
-    if ($item['type'] & MENU_VISIBLE_IN_BREADCRUMB) {
-      $links[] = menu_item_link($mid);
-    }
-  }
-
-  // The last item in the trail is the page title; don't display it here.
-  array_pop($links);
-
-  return $links;
-}
-
-/**
- * Returns TRUE when the menu item is in the active trail.
- */
-function menu_in_active_trail($mid) {
-  $trail = _menu_get_active_trail();
-
-  return in_array($mid, $trail);
-}
-
-/**
- * Returns TRUE when the menu item is in the active trail within a
- * specific subsection of the menu tree.
+ * Unserializes an array. Integer values are mapped according to the $map
+ * parameter. For example, if unserialize($data) is array('node_load', 1)
+ * and $map is array('node', '12345') then 'node_load' will not be changed
+ * because it is not an integer, but 1 will is an integer. As $map[1] is
+ * '12345', 1 will be replaced with '12345'. So the result will be
+ * array('node_load', '12345').
  *
- * @param $mid
- *   The menu item being considered.
- * @param $pid
- *   The root of the subsection of the menu tree in which to look.
- */
-function menu_in_active_trail_in_submenu($mid, $pid) {
-  $trail = _menu_get_active_trail_in_submenu($pid);
-
-  if (!$trail) {
-    return FALSE;
-  }
-
-  return in_array($mid, $trail);
-}
-
-/**
- * Populate the database representation of the menu.
- *
- * This need only be called at the start of pages that modify the menu.
+ * @param @data
+ *   A serialized array.
+ * @param @map
+ *  An array of potential replacements.
+ * @return
+ *  The $data array unserialized and mapped.
  */
-function menu_rebuild() {
-  // Clear the page cache, so that changed menus are reflected for anonymous users.
-  cache_clear_all('*', 'cache_page', TRUE);
-  // Also clear the menu cache.
-  cache_clear_all('*', 'cache_menu', TRUE);
-
-  _menu_build();
-
-  if (module_exists('menu')) {
-    $menu = menu_get_menu();
-
-    // Fill a queue of new menu items which are modifiable.
-    $new_items = array();
-    foreach ($menu['items'] as $mid => $item) {
-      if ($mid < 0 && ($item['type'] & MENU_MODIFIABLE_BY_ADMIN)) {
-        $new_items[$mid] = $item;
+function menu_unserialize($data, $map) {
+  if ($data = unserialize($data)) {
+    foreach ($data as $k => $v) {
+      if (is_int($v)) {
+        $data[$k] = isset($map[$v]) ? $map[$v] : '';
       }
     }
-
-    $old_count = -1;
-    // Save the new items updating the pids in each iteration
-    while (($c = count($new_items)) && ($c != $old_count)) {
-      $old_count = count($new_items);
-      foreach($new_items as $mid => $item) {
-        // If the item has a valid parent, save it
-        if ($item['pid'] >= 0) {
-          // The new menu ID gets passed back by reference as $item['mid']
-          menu_save_item($item);
-          // Fix parent IDs for the children of the menu item just saved
-          if ($item['children']) {
-            foreach ($item['children'] as $child) {
-              if (isset($new_items[$child])) {
-                $new_items[$child]['pid'] = $item['mid'];
-              }
-            }
-          }
-          // remove the item
-          unset($new_items[$mid]);
-        }
-      }
-    }
-    // Rebuild the menu to account for the changes.
-    _menu_build();
-  }
-
-  // Reset the cached $menu in menu_get_item().
-  menu_get_item(NULL, NULL, TRUE);
-
-}
-
-/**
- * Generate the HTML for a menu tree.
- *
- * @param $pid
- *   The parent id of the menu.
- *
- * @ingroup themeable
- */
-function theme_menu_tree($pid = 1) {
-  if ($tree = menu_tree($pid)) {
-    return "\n<ul class=\"menu\">\n". $tree ."\n</ul>\n";
+    return $data;
   }
-}
-
-/**
- * Returns a rendered menu tree.
- *
- * @param $pid
- *   The parent id of the menu.
- */
-function menu_tree($pid = 1) {
-  $menu = menu_get_menu();
-  $output = '';
-
-  if (isset($menu['visible'][$pid]) && $menu['visible'][$pid]['children']) {
-    foreach ($menu['visible'][$pid]['children'] as $mid) {
-      $type = isset($menu['visible'][$mid]['type']) ? $menu['visible'][$mid]['type'] : NULL;
-      $children = isset($menu['visible'][$mid]['children']) ? $menu['visible'][$mid]['children'] : NULL;
-      $output .= theme('menu_item', $mid, menu_in_active_trail($mid) || ($type & MENU_EXPANDED) ? theme('menu_tree', $mid) : '', count($children) == 0);
-    }
+  else {
+    return array();
   }
-
-  return $output;
 }
 
 /**
- * Generate the HTML output for a single menu item.
- *
- * @param $mid
- *   The menu id of the item.
- * @param $children
- *   A string containing any rendered child items of this menu.
- * @param $leaf
- *   A boolean indicating whether this menu item is a leaf.
- *
- * @ingroup themeable
- */
-function theme_menu_item($mid, $children = '', $leaf = TRUE) {
-  return '<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. menu_item_link($mid) . $children ."</li>\n";
-}
-
-/**
- * Generate the HTML representing a given menu item ID.
+ * Replaces the statically cached item for a given path.
  *
+ * @param $path
+ *   The path
  * @param $item
- *   The menu item to render.
- * @param $link_item
- *   The menu item which should be used to find the correct path.
- *
- * @ingroup themeable
+ *  The menu item. This is a menu entry, an associative array,
+ *  with keys like title, access callback, access arguments etc.
  */
-function theme_menu_item_link($item, $link_item) {
-  return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
+function menu_set_item($path, $item) {
+  menu_get_item($path, TRUE, $item);
 }
 
-/**
- * Returns the rendered link to a menu item.
- *
- * @param $mid
- *   The menu item id to render.
- * @param $theme
- *   Whether to return a themed link or the link as an array
- */
-function menu_item_link($mid, $theme = TRUE) {
-  $item = menu_get_item($mid);
-  $link_item = $item;
-  $link = '';
-
-  while ($link_item['type'] & MENU_LINKS_TO_PARENT) {
-    $link_item = menu_get_item($link_item['pid']);
-  }
-
-  if ($theme) {
-    $link = theme('menu_item_link', $item, $link_item);
-  }
-  else {
-    $link = array(
-      'title' => $item['title'],
-      'href' => $link_item['path'],
-      'attributes' => !empty($item['description']) ? array('title' => $item['description']) : array()
-    );
-  }
-
-  return $link;
-}
-
-/**
- * Returns the rendered local tasks. The default implementation renders
- * them as tabs.
- *
- * @ingroup themeable
- */
-function theme_menu_local_tasks() {
-  $output = '';
-
-  if ($primary = menu_primary_local_tasks()) {
-    $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
-  }
-  if ($secondary = menu_secondary_local_tasks()) {
-    $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
+function menu_get_item($path = NULL, $execute = TRUE, $item = NULL) {
+  static $items;
+  if (!isset($path)) {
+    $path = $_GET['q'];
   }
-
-  return $output;
-}
-
-/**
- * Returns the rendered HTML of the primary local tasks.
- */
-function menu_primary_local_tasks() {
-  $local_tasks = menu_get_local_tasks();
-  $pid = menu_get_active_nontask_item();
-  $output = '';
-
-  if (count($local_tasks[$pid]['children'])) {
-    foreach ($local_tasks[$pid]['children'] as $mid) {
-      $output .= theme('menu_local_task', $mid, menu_in_active_trail($mid), TRUE);
-    }
+  if (isset($item)) {
+    $items[$path] = $item;
   }
-
-  return $output;
-}
-
-/**
- * Returns the rendered HTML of the secondary local tasks.
- */
-function menu_secondary_local_tasks() {
-  $local_tasks = menu_get_local_tasks();
-  $pid = menu_get_active_nontask_item();
-  $output = '';
-
-  if (count($local_tasks[$pid]['children'])) {
-    foreach ($local_tasks[$pid]['children'] as $mid) {
-      if (menu_in_active_trail($mid) && count($local_tasks[$mid]['children']) > 1) {
-        foreach ($local_tasks[$mid]['children'] as $cid) {
-          $output .= theme('menu_local_task', $cid, menu_in_active_trail($cid), FALSE);
+  if (!isset($items[$path])) {
+    $map = arg(NULL, $path);
+    $parts = array_slice($map, 0, 6);
+    list($ancestors, $placeholders) = menu_get_ancestors($parts);
+    if ($item = db_fetch_object(db_query_range('SELECT * FROM {menu} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {
+      if ($item->map_callback) {
+        $map = call_user_func_array($item->map_callback, array_merge(array($map), unserialize($item->map_arguments)));
+        if ($map === FALSE) {
+          return FALSE;
         }
       }
+      $item->access = is_numeric($item->access_callback) ? $item->access_callback : call_user_func_array($item->access_callback, menu_unserialize($item->access_arguments, $map));
+      if ($execute) {
+        $item->page_arguments = array_merge(menu_unserialize($item->page_arguments, $map), array_slice($parts, $item->number_parts));
+      }
     }
+    $items[$path] = $item;
   }
-
-  return $output;
+  return $items[$path];
 }
 
-/**
- * Generate the HTML representing a given menu item ID as a tab.
- *
- * @param $mid
- *   The menu ID to render.
- * @param $active
- *   Whether this tab or a subtab is the active menu item.
- * @param $primary
- *   Whether this tab is a primary tab or a subtab.
- *
- * @ingroup themeable
- */
-function theme_menu_local_task($mid, $active, $primary) {
-  if ($active) {
-    return '<li class="active">'. menu_item_link($mid) ."</li>\n";
-  }
-  else {
-    return '<li>'. menu_item_link($mid) ."</li>\n";
+function menu_execute_active_handler() {
+  if ($item = menu_get_item()) {
+    return $item->access ? call_user_func_array($item->page_callback, $item->page_arguments) : MENU_ACCESS_DENIED;
   }
+  return MENU_NOT_FOUND;
 }
 
-/**
- * Returns an array containing the primary links.
- * Can optionally descend from the root of the Primary links menu towards the
- * current node for a specified number of levels and return that submenu.
- * Used to generate a primary/secondary menu from different levels of one menu.
- *
- * @param $start_level
- *   This optional parameter can be used to retrieve a context-sensitive array
- *   of links at $start_level levels deep into the Primary links menu.
- *   The default is to return the top-level links.
- * @param $pid
- *   The parent menu ID from which to search for children. Defaults to the
- *   menu_primary_menu setting.
- * @return A nested array of links and their properties. The keys of
- *   the array contain some extra encoded information about the results.
- *   The format of the key is {level}-{num}{-active}.
- *   level is the depth within the menu tree of this list.
- *   num is the number within this array, used only to make the key unique.
- *   -active is appended if this element is in the active trail.
- */
-function menu_primary_links($start_level = 1, $pid = 0) {
-  if (!module_exists('menu')) {
-    return NULL;
-  }
-  if (!$pid) {
-    $pid = variable_get('menu_primary_menu', 0);
-  }
-  if (!$pid) {
-    return NULL;
-  }
-
-  if ($start_level < 1) {
-    $start_level = 1;
-  }
-
-  if ($start_level > 1) {
-    $trail = _menu_get_active_trail_in_submenu($pid);
-    if (!$trail) {
-      return NULL;
-    }
-    else {
-      $pid = $trail[$start_level - 1];
-    }
-  }
-
-  $menu = menu_get_menu();
-  $links = array();
-  if ($pid && is_array($menu['visible'][$pid]) && isset($menu['visible'][$pid]['children'])) {
-    $count = 1;
-    foreach ($menu['visible'][$pid]['children'] as $cid) {
-      $index = "menu-$start_level-$count-$pid";
-      if (menu_in_active_trail_in_submenu($cid, $pid)) {
-        $index .= "-active";
-      }
-      $links[$index] = menu_item_link($cid, FALSE);
-      $count++;
-    }
-  }
+// placeholders
+function menu_get_active_breadcrumb() {
+  return array(l(t('home'), ''));
+}
 
-  // Special case - provide link to admin/build/menu if primary links is empty.
-  if (empty($links) && $start_level == 1 && $pid == variable_get('menu_primary_menu', 0) && user_access('administer menu')) {
-    $links['1-1'] = array(
-      'title' => t('Edit primary links'),
-      'href' => 'admin/build/menu'
-    );
-  }
+function menu_get_active_help() {
+}
 
-  return $links;
+function menu_primary_links() {
 }
 
-/**
- * Returns an array containing the secondary links.
- * Secondary links can be either a second level of the Primary links
- * menu or generated from their own menu.
- */
 function menu_secondary_links() {
-  $msm = variable_get('menu_secondary_menu', 0);
-  if ($msm == 0) {
-    return NULL;
-  }
-
-  if ($msm == variable_get('menu_primary_menu', 0)) {
-    return menu_primary_links(2, $msm);
-  }
-
-  return menu_primary_links(1, $msm);
 }
 
-/**
- * Returns the themed HTML for primary and secondary links.
- * Note that this function is overridden by most core themes because
- * those themes display links in "link | link" format, not from a list.
- * Also note that by default links rendered with this function are
- * displayed with the same CSS as is used for the local tasks.
- * If a theme wishes to render links from a ul it is expected that
- * the theme will provide suitable CSS.
- *
- * @param $links
- *   An array containing links to render.
- * @return
- *   A string containing the themed links.
- *
- * @ingroup themeable
- */
-function theme_menu_links($links) {
-  if (!count($links)) {
-    return '';
-  }
-  $level_tmp = explode('-', key($links));
-  $level = $level_tmp[0];
-  $output = "<ul class=\"links-$level\">\n";
-  foreach ($links as $index => $link) {
-    $output .= '<li';
-    if (stristr($index, 'active')) {
-      $output .= ' class="active"';
-    }
-    $output .= ">". l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']) ."</li>\n";
-  }
-  $output .= '</ul>';
-
-  return $output;
+function menu_primary_local_tasks() {
 }
 
-/**
- * @} End of "defgroup menu".
- */
-
-/**
- * Returns an array with the menu items that lead to the current menu item.
- */
-function _menu_get_active_trail() {
-  static $trail;
-
-  if (!isset($trail)) {
-    $trail = array();
-
-    $mid = menu_get_active_item();
-
-    // Follow the parents up the chain to get the trail.
-    while ($mid && ($item = menu_get_item($mid))) {
-      array_unshift($trail, $mid);
-      $mid = $item['pid'];
-    }
-  }
-  return $trail;
+function menu_secondary_local_tasks() {
 }
 
-/**
- * Find the active trail through a specific subsection of the menu tree.
- *
- * @param $pid
- *   The root item from which the active trail must descend.
- */
-function _menu_get_active_trail_in_submenu($pid) {
-  static $trails;
-
-  if (!isset($trails)) {
-    // Find all menu items which point to the current node and for each
-    // follow the parents up the chain to build an active trail.
-    $trails = array();
-    $menu = menu_get_menu();
-    $path = $_GET['q'];
-    $count = 0;
-    while ($path && !$count) {
-      foreach ($menu['items'] as $key => $item) {
-        if (isset($item['path']) && $item['path'] == $path) {
-          $trails[$count] = array();
-          $mid = $key;
-          while ($mid && $menu['items'][$mid]) {
-            array_unshift($trails[$count], $mid);
-            $mid = $menu['items'][$mid]['pid'];
-          }
-          $count ++;
-        }
-      }
-      $path = substr($path, 0, strrpos($path, '/'));
-    }
-  }
-
-  if ($trails) {
-    foreach ($trails as $trail) {
-      $count_trail = count($trail);
-      for ($i = 0; $i < $count_trail; $i++) {
-        if ($trail[$i] == $pid) {
-          // Return a trail from $pid down to the current page inclusive.
-          for ( ; $i < $count_trail; $i++) {
-            $subtrail[] = $trail[$i];
-          }
-          return $subtrail;
-        }
-      }
-    }
-  }
-
-  return NULL;
+function menu_set_active_item() {
 }
 
-/**
- * Comparator routine for use in sorting menu items.
- */
-function _menu_sort($a, $b) {
+function menu_rebuild() {
+  db_query('DELETE FROM {menu}');
   $menu = menu_get_menu();
-
-  $a = &$menu['items'][$a];
-  $b = &$menu['items'][$b];
-
-  if ($a['weight'] < $b['weight']) {
-    return -1;
-  }
-  elseif ($a['weight'] > $b['weight']) {
-    return 1;
-  }
-  elseif (isset($a['title']) && isset($b['title'])) {
-    return strnatcasecmp($a['title'], $b['title']);
-  }
-  else {
-    return 1;
-  }
-}
-
-/**
- * Build the menu by querying both modules and the database.
- */
-function _menu_build() {
-  global $_menu;
-  global $user;
-
-  // Start from a clean slate.
-  $_menu = array();
-
-  $_menu['path index'] = array();
-  // Set up items array, including default "Navigation" menu.
-  $_menu['items'] = array(
-    0 => array('path' => '', 'title' => '', 'type' => MENU_IS_ROOT),
-    1 => array('pid' => 0, 'path' => '', 'title' => t('Navigation'), 'weight' => -50, 'access' => TRUE, 'type' => MENU_IS_ROOT | MENU_VISIBLE_IN_TREE)
-    );
-  $_menu['callbacks'] = array();
-
-  // Build a sequential list of all menu items.
-  $menu_item_list = module_invoke_all('menu', TRUE);
-
-  // Menu items not in the DB get temporary negative IDs.
-  $temp_mid = -1;
-
-  foreach ($menu_item_list as $item) {
-    if (!isset($item['path'])) {
-      $item['path'] = '';
-    }
-    if (!isset($item['type'])) {
-      $item['type'] = MENU_NORMAL_ITEM;
-    }
-    if (!isset($item['weight'])) {
-      $item['weight'] = 0;
-    }
-    $mid = $temp_mid;
-    if (isset($_menu['path index'][$item['path']])) {
-      // Newer menu items overwrite older ones.
-      unset($_menu['items'][$_menu['path index'][$item['path']]]);
-    }
-    if (isset($item['callback'])) {
-      $_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
-      if (isset($item['callback arguments'])) {
-        $_menu['callbacks'][$item['path']]['callback arguments'] = $item['callback arguments'];
-        unset($item['callback arguments']);
-      }
-      unset($item['callback']);
-    }
-    $_menu['items'][$mid] = $item;
-    $_menu['path index'][$item['path']] = $mid;
-
-    $temp_mid--;
-  }
-
-  // Now fetch items from the DB, reassigning menu IDs as needed.
-  if (module_exists('menu')) {
-    $result = db_query(db_rewrite_sql('SELECT m.mid, m.* FROM {menu} m ORDER BY m.mid ASC', 'm', 'mid'));
-    while ($item = db_fetch_object($result)) {
-      // Handle URL aliases if entered in menu administration.
-      if (!isset($_menu['path index'][$item->path])) {
-        $item->path = drupal_get_normal_path($item->path);
-      }
-      if (isset($_menu['path index'][$item->path])) {
-        // The path is already declared.
-        $old_mid = $_menu['path index'][$item->path];
-        if ($old_mid < 0) {
-          // It had a temporary ID, so use a permanent one.
-          $_menu['items'][$item->mid] = $_menu['items'][$old_mid];
-          if ($_menu['items'][$item->mid]['type'] & $item->type) {
-            // If the item is of the same type, delete the old item.
-            unset($_menu['items'][$old_mid]);
-            $_menu['path index'][$item->path] = $item->mid;
-          }
-          // The new menu item gets all the custom type flags from the database
-          $_menu['items'][$item->mid]['type'] &= $item->type;
-        }
-        else {
-          // It has a permanent ID. Only replace with non-custom menu items.
-          if ($item->type & MENU_CREATED_BY_ADMIN) {
-            $_menu['items'][$item->mid] = array('path' => $item->path);
-          }
-          else {
-            // Leave the old item around as a shortcut to this one.
-            $_menu['items'][$item->mid] = $_menu['items'][$old_mid];
-            $_menu['path index'][$item->path] = $item->mid;
-          }
-        }
-      }
-      else {
-        // The path was not declared, so this is a custom item or an orphaned one.
-        if ($item->type & MENU_CREATED_BY_ADMIN) {
-          $_menu['items'][$item->mid] = array('path' => $item->path);
-          if (!empty($item->path)) {
-            $_menu['path index'][$item->path] = $item->mid;
+  foreach ($menu as $path => $item) {
+    // we will change heavily item
+    $item = &$menu[$path];
+    $n = count($item['_parts']);
+    for ($i = $n - 1; $i; $i--) {
+      $parent_path = implode('/', array_slice($item['_parts'], 0, $i));
+      if (!isset($menu[$parent_path])) {
+        continue;
+      }
+      $parent = $menu[$parent_path];
+      // If a callback is not found, we try to find the first parent that
+      // has this callback. When found, its callback argument will also be 
+      // copied but only if there is none in the current item.
+      foreach (array('access', 'map', 'page') as $type) {
+        if (!isset($item["$type callback"]) && isset($parent["$type callback"])) {
+          $menu[$path]["$type callback"] = $parent["$type callback"];
+          if (!isset($item["$type arguments"]) && isset($parent["$type arguments"])) {
+            $menu[$path]["$type arguments"] = $parent["$type arguments"];
           }
         }
       }
-
-      // If the administrator has changed the item, reflect the change.
-      if ($item->type & MENU_MODIFIED_BY_ADMIN) {
-        $_menu['items'][$item->mid]['title'] = $item->title;
-        $_menu['items'][$item->mid]['description'] = $item->description;
-        $_menu['items'][$item->mid]['pid'] = $item->pid;
-        $_menu['items'][$item->mid]['weight'] = $item->weight;
-        $_menu['items'][$item->mid]['type'] = $item->type;
-      }
-    }
-  }
-
-  // Associate parent and child menu items.
-  _menu_find_parents($_menu['items']);
-
-  // Prepare to display trees to the user as required.
-  _menu_build_visible_tree();
-}
-
-/**
- * Determine whether the given menu item is accessible to the current user.
- *
- * Use this instead of just checking the "access" property of a menu item
- * to properly handle items with fall-through semantics.
- */
-function _menu_item_is_accessible($mid) {
-  $menu = menu_get_menu();
-
-  // Follow the path up to find the first "access" attribute.
-  $path = isset($menu['items'][$mid]['path']) ? $menu['items'][$mid]['path'] : NULL;
-  while ($path && (!isset($menu['path index'][$path]) || !isset($menu['items'][$menu['path index'][$path]]['access']))) {
-    $path = substr($path, 0, strrpos($path, '/'));
-  }
-  if (empty($path)) {
-    // Items without any access attribute up the chain are denied, unless they
-    // were created by the admin. They most likely point to non-Drupal directories
-    // or to an external URL and should be allowed.
-    return $menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN;
-  }
-  return $menu['items'][$menu['path index'][$path]]['access'];
-}
-
-/**
- * Find all visible items in the menu tree, for ease in displaying to user.
- *
- * Since this is only for display, we only need title, path, and children
- * for each item.
- */
-function _menu_build_visible_tree($pid = 0) {
-  global $_menu;
-
-  if (isset($_menu['items'][$pid])) {
-    $parent = $_menu['items'][$pid];
-
-    $children = array();
-    if (isset($parent['children'])) {
-      usort($parent['children'], '_menu_sort');
-      foreach ($parent['children'] as $mid) {
-        $children = array_merge($children, _menu_build_visible_tree($mid));
-      }
+      // parents & breadcrumb will be built here
     }
-    $visible = ($parent['type'] & MENU_VISIBLE_IN_TREE) ||
-      ($parent['type'] & MENU_VISIBLE_IF_HAS_CHILDREN && count($children) > 0);
-    $allowed = _menu_item_is_accessible($pid);
-
-    if (($parent['type'] & MENU_IS_ROOT) || ($visible && $allowed)) {
-      $_menu['visible'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children, 'type' => $parent['type']);
-      foreach ($children as $mid) {
-        $_menu['visible'][$mid]['pid'] = $pid;
-      }
-      return array($pid);
+    if (!isset($item['access callback'])) {
+      $menu[$path]['access callback'] = isset($item['access arguments']) ? 'user_access' : 0;
     }
-    else {
-      return $children;
+    if (!isset($item['map callback']) && isset($item['map arguments'])) {
+      $item['map callback'] = 'menu_map';
     }
-  }
-
-  return array();
-}
-
-/**
- * Account for menu items that are only defined at certain paths, so will not
- * be cached.
- *
- * We don't support the full range of menu item options for these menu items. We
- * don't support MENU_VISIBLE_IF_HAS_CHILDREN, and we require parent items to be
- * declared before their children.
- */
-function _menu_append_contextual_items() {
-  global $_menu;
-
-  // Build a sequential list of all menu items.
-  $menu_item_list = module_invoke_all('menu', FALSE);
-
-  // Menu items not in the DB get temporary negative IDs.
-  $temp_mid = min(array_keys($_menu['items'])) - 1;
-  $new_items = array();
-
-  foreach ($menu_item_list as $item) {
-    if (isset($item['callback'])) {
-      $_menu['callbacks'][$item['path']] = array('callback' => $item['callback']);
-      if (isset($item['callback arguments'])) {
-        $_menu['callbacks'][$item['path']]['callback arguments'] = $item['callback arguments'];
-        unset($item['callback arguments']);
+    foreach (array('access', 'map', 'page') as $type) {
+      if (isset($item["$type callback"]) && !isset($item["$type arguments"])) {
+        $item["$type arguments"] = array();
       }
-      unset($item['callback']);
-    }
-    if (!isset($_menu['path index'][$item['path']])) {
-      if (!isset($item['path'])) {
-        $item['path'] = '';
-      }
-      if (!isset($item['type'])) {
-        $item['type'] = MENU_NORMAL_ITEM;
-      }
-      if (!isset($item['weight'])) {
-        $item['weight'] = 0;
-      }
-      $_menu['items'][$temp_mid] = $item;
-      $_menu['path index'][$item['path']] = $temp_mid;
-      $new_items[$temp_mid] = $item;
-      $temp_mid--;
-    }
-    else {
-      $mid = $_menu['path index'][$item['path']];
-      if ($_menu['items'][$mid]['type'] & MENU_CREATED_BY_ADMIN) {
-        $_menu['items'][$mid]['access'] = $item['access'];
-        if (isset($_menu['items'][$mid]['callback'])) {
-          $_menu['items'][$mid]['callback'] = $item['callback'];
-        }
-        if (isset($_menu['items'][$mid]['callback arguments'])) {
-          $_menu['items'][$mid]['callback arguments'] = $item['callback arguments'];
-        }
-      }
-      if ($item['type'] & MENU_LOCAL_TASK && !($_menu['items'][$mid]['type'] & MENU_LOCAL_TASK)) {
-        // A local task is in the menu table and the path is already present
-        $_menu['items'][$mid]['type'] = MENU_LOCAL_TASK;
-        $new_items[$mid] = $item;
-      }
-    }
-  }
-
-  // Establish parent-child relationships.
-  _menu_find_parents($new_items);
-
-  // Add new items to the visible tree if necessary.
-  foreach ($new_items as $mid => $item) {
-    $item = $_menu['items'][$mid];
-    if (($item['type'] & MENU_VISIBLE_IN_TREE) && _menu_item_is_accessible($mid)) {
-      $pid = $item['pid'];
-      while ($pid && !isset($_menu['visible'][$pid])) {
-        $pid = $_menu['items'][$pid]['pid'];
-      }
-      $_menu['visible'][$mid] = array('title' => $item['title'], 'path' => $item['path'], 'pid' => $pid);
-      $_menu['visible'][$pid]['children'][] = $mid;
-      usort($_menu['visible'][$pid]['children'], '_menu_sort');
     }
+    db_query("INSERT INTO {menu} (path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)", $path, $item['access callback'], serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['map callback'], serialize($item['map arguments']), $item['_fit'], $item['_number_parts']);
+    // item needs to be unset because of the reference above
+    unset($item);
   }
 }
 
-/**
- * Establish parent-child relationships.
- */
-function _menu_find_parents(&$items) {
-  global $_menu;
-
-  foreach ($items as $mid => $item) {
-    if (!isset($item['pid'])) {
-      // Parent's location has not been customized, so figure it out using the path.
-      $parent = $item['path'];
-      if ($parent) {
-        do {
-          $parent = substr($parent, 0, strrpos($parent, '/'));
-        }
-        while ($parent && !isset($_menu['path index'][$parent]));
-      }
-
-      $pid = $parent ? $_menu['path index'][$parent] : 1;
-      $_menu['items'][$mid]['pid'] = $pid;
-    }
-    else {
-      $pid = $item['pid'];
-    }
-
-    // Don't make root a child of itself.
-    if ($mid) {
-      if (isset ($_menu['items'][$pid])) {
-        $_menu['items'][$pid]['children'][] = $mid;
-      }
-      else {
-        // If parent is missing, it is a menu item that used to be defined
-        // but is no longer. Default to a root-level "Navigation" menu item.
-        $_menu['items'][1]['children'][] = $mid;
-      }
-    }
-  }
+function menu_access_and($perm, $arg) {
+  return user_access($perm) && $arg;
 }
 
-/**
- * Find all the items in the current local task tree.
- *
- * Since this is only for display, we only need title, path, and children
- * for each item.
- *
- * At the close of this function, $_menu['local tasks'] is populated with the
- * menu items in the local task tree.
- *
- * @return
- *   TRUE if the local task tree is forked. It does not need to be displayed
- *   otherwise.
- */
-function _menu_build_local_tasks($pid) {
-  global $_menu;
-
-  $forked = FALSE;
-
-  if (isset($_menu['items'][$pid])) {
-    $parent = $_menu['items'][$pid];
-
-    $children = array();
-    if (isset($parent['children'])) {
-      foreach ($parent['children'] as $mid) {
-        if (($_menu['items'][$mid]['type'] & MENU_IS_LOCAL_TASK) && _menu_item_is_accessible($mid)) {
-          $children[] = $mid;
-          // Beware short-circuiting || operator!
-          $forked = _menu_build_local_tasks($mid) || $forked;
-        }
-      }
-    }
-    usort($children, '_menu_sort');
-    $forked = $forked || count($children) > 1;
-
-    $_menu['local tasks'][$pid] = array('title' => $parent['title'], 'path' => $parent['path'], 'children' => $children);
-    foreach ($children as $mid) {
-      $_menu['local tasks'][$mid]['pid'] = $pid;
-    }
-  }
-
-  return $forked;
+function menu_map($arg, $function, $index, $default = FALSE) {
+  $arg[$index] = is_numeric($arg[$index]) ? $function($arg[$index]) : $default;
+  return $arg[$index] ? $arg : FALSE;
 }
 
-/**
- * Returns TRUE if the site is off-line for maintenance.
- */
-function _menu_site_is_offline() {
-  // Check if site is set to off-line mode
-  if (variable_get('site_offline', 0)) {
-    // Check if the user has administration privileges
-    if (!user_access('administer site configuration')) {
-      // Check if this is an attempt to login
-      if (drupal_get_normal_path($_GET['q']) != 'user') {
-        return TRUE;
-      }
+function menu_get_menu() {
+  $menu = module_invoke_all('menu');
+  foreach (module_implements('menu_alter') as $module) {
+    $function = $module .'_menu_alter';
+    $function($menu);
+  }
+  $known_keys = array(
+    'description',
+    'map callback',
+    'map arguments',
+    'access arguments',
+    'access callback',
+    'page callback',
+    'page arguments',
+    'title',
+    'type',
+    'weight',
+    'position',
+    'block callback',
+  );
+  foreach ($menu as $path => $item) {
+    if ($diff = array_diff(array_keys($item), $known_keys)) echo "$path<br>";
+    $parts = explode('/', $path, 6);
+    $number_parts = count($parts);
+    // we store the highest index of parts here to save some work in the weight
+    // calculation loop
+    $slashes = $number_parts - 1;
+    // if there is no %, it fits maximally
+    if (strpos($path, '%') === FALSE) {
+      $fit = (1 << $number_parts) - 1;
     }
     else {
-      $offline_message = t('Operating in off-line mode.');
-      $messages = drupal_set_message();
-      // Ensure that the off-line message is displayed only once [allowing for page redirects].
-      if (!isset($messages) || !isset($messages['status']) || !in_array($offline_message, $messages['status'])) {
-        drupal_set_message($offline_message);
-      }
-    }
-  }
-  return FALSE;
+      // we need to calculate the fitness
+      $fit = 0;
+      foreach ($parts as $k => $part) {
+        // ($part != '%') is the bit we want and we shift it to its place
+        // by shifting to left by ($slashes - $k) bits
+        $fit |=  ($part != '%') << ($slashes - $k);
+      }
+    }
+    $menu[$path]['_fit'] = $fit;
+    $menu[$path]['_number_parts'] = $number_parts;
+    $menu[$path]['_parts'] = $parts;
+    $sort[$path] = $fit; // we will add weights and title to this
+  }
+  // inheritance can only work if the ancestors come first
+  array_multisort($sort, SORT_NUMERIC, $menu);
+  return $menu;
 }

=== modified file 'includes/pager.inc'
--- includes/pager.inc	2006-10-15 19:57:05 +0000
+++ includes/pager.inc	2006-12-17 14:10:52 +0000
@@ -60,9 +60,10 @@ function pager_query($query, $limit = 10
     $args = $args[0];
   }
 
-  // Construct a count query if none was given.
+  // Construct a count query if none was given. Mysql demands that every 
+  /// derived table must have its own alias
   if (!isset($count_query)) {
-    $count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''), $query);
+    $count_query = "SELECT COUNT(*) FROM ($query) derived_table";
   }
 
   // Convert comma-separated $page to an array, used by other functions.

=== modified file 'includes/path.inc'
--- includes/path.inc	2006-12-23 22:04:52 +0000
+++ includes/path.inc	2006-12-30 17:22:36 +0000
@@ -145,16 +145,20 @@ function drupal_get_normal_path($path) {
  *   The component specified by $index, or FALSE if the specified component was
  *   not found.
  */
-function arg($index) {
-  static $arguments, $q;
+function arg($index = NULL, $path = NULL) {
+  static $arguments;
 
-  if (empty($arguments) || $q != $_GET['q']) {
-    $arguments = explode('/', $_GET['q']);
-    $q = $_GET['q'];
+  if (!isset($path)) {
+    $path = $_GET['q'];
   }
-
-  if (isset($arguments[$index])) {
-    return $arguments[$index];
+  if (!isset($arguments[$path])) {
+    $arguments[$path] = explode('/', $path);
+  }
+  if (!isset($index)) {
+    return $arguments[$path];
+  }
+  if (isset($arguments[$path][$index])) {
+    return $arguments[$path][$index];
   }
 }
 

=== modified file 'index.php'
--- index.php	2006-12-12 09:32:18 +0000
+++ index.php	2006-12-15 14:18:03 +0000
@@ -12,6 +12,7 @@
 require_once './includes/bootstrap.inc';
 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
+menu_rebuild();
 $return = menu_execute_active_handler();
 
 // Menu status constants are integers; page content is a string.
@@ -34,4 +35,4 @@ elseif (isset($return)) {
 
 }
 
-drupal_page_footer();
\ No newline at end of file
+drupal_page_footer();

=== modified file 'install.php'
--- install.php	2006-12-30 09:06:22 +0000
+++ install.php	2006-12-30 17:22:32 +0000
@@ -530,6 +530,7 @@ function install_complete($profile) {
   // Bootstrap newly installed Drupal, while preserving existing messages.
   $messages = $_SESSION['messages'];
   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+  menu_rebuild();
   $_SESSION['messages'] = $messages;
 
   // Build final page.

=== modified file 'modules/aggregator/aggregator.module'
--- modules/aggregator/aggregator.module	2006-12-26 10:28:12 +0000
+++ modules/aggregator/aggregator.module	2006-12-30 17:22:32 +0000
@@ -28,169 +28,158 @@ function aggregator_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function aggregator_menu($may_cache) {
-  $items = array();
-  $edit = user_access('administer news feeds');
-  $view = user_access('access news feeds');
-
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/content/aggregator',
-      'title' => t('News aggregator'),
-      'description' => t("Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized."),
-      'callback' => 'aggregator_admin_overview',
-      'access' => $edit);
-    $items[] = array('path' => 'admin/content/aggregator/add/feed',
-      'title' => t('Add feed'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('aggregator_form_feed'),
-      'access' => $edit,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/content/aggregator/add/category',
-      'title' => t('Add category'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('aggregator_form_category'),
-      'access' => $edit,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/content/aggregator/remove',
-      'title' => t('Remove items'),
-      'callback' => 'aggregator_admin_remove_feed',
-      'access' => $edit,
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/content/aggregator/update',
-      'title' => t('Update items'),
-      'callback' => 'aggregator_admin_refresh_feed',
-      'access' => $edit,
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/content/aggregator/list',
-      'title' => t('List'),
+function aggregator_menu() {
+  $items['admin/content/aggregator'] = array(
+    'title' => t('News aggregator'),
+    'description' => t("Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized."),
+    'page callback' => 'aggregator_admin_overview',
+    'access arguments' => array('administer news feeds'),
+  );
+  $items['admin/content/aggregator/add/feed'] = array(
+    'title' => t('Add feed'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('aggregator_form_feed'),
+    'access arguments' => array('administer news feeds'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/content/aggregator/add/category'] = array(
+    'title' => t('Add category'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('aggregator_form_category'),
+    'access arguments' => array('administer news feeds'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/content/aggregator/remove'] = array(
+    'title' => t('Remove items'),
+    'page callback' => 'aggregator_admin_remove_feed',
+    'access arguments' => array('administer news feeds'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/content/aggregator/update'] = array(
+    'title' => t('Update items'),
+    'page callback' => 'aggregator_admin_refresh_feed',
+    'access arguments' => array('administer news feeds'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/content/aggregator/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/content/aggregator/settings'] = array(
+    'title' => t('Settings'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('aggregator_admin_settings'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10,
+    'access arguments' => array('administer news feeds'),
+  );
+  $items['aggregator'] = array(
+    'title' => t('News aggregator'),
+    'page callback' => 'aggregator_page_last',
+    'access arguments' => array('access news feeds'),
+    'weight' => 5,
+  );
+  $items['aggregator/sources'] = array(
+    'title' => t('Sources'),
+    'page callback' => 'aggregator_page_sources',
+    'access arguments' => array('access news feeds'));
+  $items['aggregator/categories'] = array(
+    'title' => t('Categories'),
+    'page callback' => 'aggregator_page_categories',
+    'access arguments' => array('access news feeds'),
+    'type' => MENU_ITEM_GROUPING,
+  );
+  $items['aggregator/rss'] = array(
+    'title' => t('RSS feed'),
+    'page callback' => 'aggregator_page_rss',
+    'access arguments' => array('access news feeds'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['aggregator/opml'] = array(
+    'title' => t('OPML feed'),
+    'page callback' => 'aggregator_page_opml',
+    'access arguments' => array('access news feeds'),
+    'type' => MENU_CALLBACK,
+  );
+  $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
+  while ($category = db_fetch_array($result)) {
+    $path = 'aggregator/categories/'. $category['cid'];
+    $items[$path] = array(
+      'title' => $category['title'],
+      'page callback' => 'aggregator_page_category',
+      'access arguments' => array('access news feeds'),
+    );
+    $items[$path .'/view'] = array(
+      'title' => t('View'),
       'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10);
-    $items[] = array('path' => 'admin/content/aggregator/settings',
-      'title' => t('Settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('aggregator_admin_settings'),
+      'weight' => -10,
+    );
+    $items[$path .'/categorize'] = array(
+      'title' => t('Categorize'),
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('aggregator_page_category'),
+      'access arguments' => array('administer news feeds', 2),
       'type' => MENU_LOCAL_TASK,
-      'weight' => 10,
-      'access' => $edit);
-
-    $items[] = array('path' => 'aggregator',
-      'title' => t('News aggregator'),
-      'callback' => 'aggregator_page_last',
-      'access' => $view,
-      'weight' => 5);
-    $items[] = array('path' => 'aggregator/sources',
-      'title' => t('Sources'),
-      'callback' => 'aggregator_page_sources',
-      'access' => $view);
-    $items[] = array('path' => 'aggregator/categories',
-      'title' => t('Categories'),
-      'callback' => 'aggregator_page_categories',
-      'access' => $view,
-      'type' => MENU_ITEM_GROUPING);
-    $items[] = array('path' => 'aggregator/rss',
-      'title' => t('RSS feed'),
-      'callback' => 'aggregator_page_rss',
-      'access' => $view,
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'aggregator/opml',
-      'title' => t('OPML feed'),
-      'callback' => 'aggregator_page_opml',
-      'access' => $view,
-      'type' => MENU_CALLBACK);
-
-    $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
-    while ($category = db_fetch_array($result)) {
-      $items[] = array('path' => 'aggregator/categories/'. $category['cid'],
-        'title' => $category['title'],
-        'callback' => 'aggregator_page_category',
-        'access' => $view);
-    }
-  }
-  else {
-    // Add the CSS for this module
-    // We put this in !$may_cache so it's only added once per request
-    drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
-
-    if (arg(0) == 'aggregator' && is_numeric(arg(2))) {
-      if (arg(1) == 'sources') {
-        $feed = aggregator_get_feed(arg(2));
-        if ($feed) {
-          $items[] = array('path' => 'aggregator/sources/'. $feed['fid'],
-            'title' => $feed['title'],
-            'callback' => 'aggregator_page_source',
-            'access' => $view,
-            'type' => MENU_CALLBACK);
-          $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/view',
-            'title' => t('View'),
-            'type' => MENU_DEFAULT_LOCAL_TASK,
-            'weight' => -10);
-          $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/categorize',
-            'title' => t('Categorize'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('aggregator_page_source'),
-            'access' => $edit,
-            'type' => MENU_LOCAL_TASK);
-          $items[] = array('path' => 'aggregator/sources/'. $feed['fid'] .'/configure',
-            'title' => t('Configure'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('aggregator_form_feed', $feed),
-            'access' => $edit,
-            'type' => MENU_LOCAL_TASK,
-            'weight' => 1);
-        }
-      }
-      else if (arg(1) == 'categories') {
-        $category = aggregator_get_category(arg(2));
-        if ($category) {
-          $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/view',
-            'title' => t('View'),
-            'type' => MENU_DEFAULT_LOCAL_TASK,
-            'weight' => -10);
-          $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/categorize',
-            'title' => t('Categorize'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('aggregator_page_category'),
-            'access' => $edit,
-            'type' => MENU_LOCAL_TASK);
-          $items[] = array('path' => 'aggregator/categories/'. $category['cid'] .'/configure',
-            'title' => t('Configure'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('aggregator_form_category', $category),
-            'access' => $edit,
-            'type' => MENU_LOCAL_TASK,
-            'weight' => 1);
-        }
-      }
-    }
-    else if (arg(2) == 'aggregator' && is_numeric(arg(5))) {
-      if (arg(4) == 'feed') {
-        $feed = aggregator_get_feed(arg(5));
-        if ($feed) {
-          $items[] = array('path' => 'admin/content/aggregator/edit/feed/'. $feed['fid'],
-            'title' => t('Edit feed'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('aggregator_form_feed', $feed),
-            'access' => $edit,
-            'type' => MENU_CALLBACK);
-        }
-      }
-      else {
-        $category = aggregator_get_category(arg(5));
-        if ($category) {
-          $items[] = array('path' => 'admin/content/aggregator/edit/category/'. $category['cid'],
-            'title' => t('Edit category'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('aggregator_form_category', $category),
-            'access' => $edit,
-            'type' => MENU_CALLBACK);
-        }
-      }
-    }
+    );
+    $items[$path .'/configure'] = array(
+      'title' => t('Configure'),
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('aggregator_form_category', 2),
+      'access arguments' => array('administer news feeds', 2),
+      'type' => MENU_LOCAL_TASK,
+      'weight' => 1,
+    );
   }
+  $items['aggregator/sources/%'] = array(
+    'page callback' => 'aggregator_page_source',
+    'map arguments' => array('aggregator_get_feed', 2),
+    'type' => MENU_CALLBACK,
+  );
+  $items['aggregator/sources/%/view'] = array(
+    'title' => t('View'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['aggregator/sources/%/categorize'] = array(
+    'title' => t('Categorize'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('aggregator_page_source'),
+    'access arguments' => array('administer news feeds', 2),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['aggregator/sources/%/configure'] = array(
+    'title' => t('Configure'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('aggregator_form_feed', 2),
+    'access arguments' => array('administer news feeds', 2),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 1,
+  );
+  $items['admin/content/aggregator/edit'] = array(
+    'page callback' => 'drupal_get_form',
+    'access arguments' => array('administer news feeds'),
+  );
+  $items['admin/content/aggregator/edit/feed/%'] = array(
+    'title' => t('Edit feed'),
+    'page arguments' => array('aggregator_form_feed', 5),
+    'map arguments' => array('aggregator_get_feed', 5),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/content/aggregator/edit/category/%'] = array(
+    'title' => t('Edit category'),
+    'page arguments' => array('aggregator_form_category', 5),
+    'map arguments' => array('aggregator_get_category', 5),
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
 
+function aggregator_start() {
+  drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
+}
+
 function aggregator_admin_settings() {
   $items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
   $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
@@ -1038,6 +1027,7 @@ function aggregator_page_last() {
  */
 function aggregator_page_source() {
   $feed = db_fetch_object(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', arg(2)));
+  drupal_set_title($feed['title']);
   $info = theme('aggregator_feed', $feed);
 
   return _aggregator_page_list('SELECT * FROM {aggregator_item} WHERE fid = '. $feed->fid .' ORDER BY timestamp DESC, iid DESC', arg(3), $info);

=== modified file 'modules/block/block.module'
--- modules/block/block.module	2006-12-18 21:49:39 +0000
+++ modules/block/block.module	2006-12-30 17:06:20 +0000
@@ -58,48 +58,43 @@ function block_perm() {
 /**
  * Implementation of hook_menu().
  */
-function block_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/build/block',
-      'title' => t('Blocks'),
-      'access' => user_access('administer blocks'),
-      'description' => t('Configure what block content appears in your site\'s sidebars and other regions.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('block_admin_display'));
-    $items[] = array('path' => 'admin/build/block/list', 'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-    $items[] = array('path' => 'admin/build/block/configure', 'title' => t('Configure block'),
-      'access' => user_access('administer blocks'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('block_admin_configure'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/build/block/delete', 'title' => t('Delete block'),
-      'access' => user_access('administer blocks'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('block_box_delete'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/build/block/add', 'title' => t('Add block'),
-      'access' => user_access('administer blocks'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('block_box_form'),
-      'type' => MENU_LOCAL_TASK);
-    $default = variable_get('theme_default', 'garland');
-    foreach (list_themes() as $key => $theme) {
-      $items[] = array(
-        'path' => 'admin/build/block/list/'. $key,
-        'title' => t('!key settings', array('!key' => $key)),
-        'callback' => 'drupal_get_form',
-        'callback arguments' => array('block_admin_display', $key),
-        'access' => user_access('administer blocks'),
-        'type' => $key == $default ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
-        'weight' => $key == $default ? -10 : 0,
-      );
-    }
+function block_menu() {
+  $items['admin/build/block'] = array(
+    'title' => t('Blocks'),
+    'description' => t('Configure what block content appears in your site\'s sidebars and other regions.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('block_admin_display'),
+    'access arguments' => array('administer blocks'),
+  );
+  $items['admin/build/block/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK, 
+    'weight' => -10,
+  );
+  $items['admin/build/block/configure'] = array(
+    'title' => t('Configure block'),
+    'page arguments' => array('block_admin_configure'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/block/delete'] = array(
+    'title' => t('Delete block'),
+    'page arguments' => array('block_box_delete'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/block/add'] = array(
+    'title' => t('Add block'),
+    'page arguments' => array('block_box_form'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $default = variable_get('theme_default', 'garland');
+  foreach (list_themes() as $key => $theme) {
+    $items['admin/build/block/list/'. $key] = array(
+      'title' => t('!key settings', array('!key' => $key)),
+      'page arguments' => array('block_admin_display', $key),
+      'type' => $key== $default ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+      'weight' => $key == $default ? -10 : 0,
+    );
   }
-
   return $items;
 }
 

=== modified file 'modules/blog/blog.module'
--- modules/blog/blog.module	2006-12-10 20:34:03 +0000
+++ modules/blog/blog.module	2006-12-14 22:27:19 +0000
@@ -249,19 +249,18 @@ function blog_link($type, $node = NULL, 
 /**
  * Implementation of hook_menu().
  */
-function blog_menu($may_cache) {
-  global $user;
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'blog', 'title' => t('Blogs'),
-      'callback' => 'blog_page',
-      'access' => user_access('access content'),
-      'type' => MENU_SUGGESTED_ITEM);
-    $items[] = array('path' => 'blog/'. $user->uid, 'title' => t('My blog'),
-      'access' => user_access('edit own blog'),
-      'type' => MENU_DYNAMIC_ITEM);
-  }
+function blog_menu() {
+  $items['blog'] = array(
+    'title' => t('Blogs'),
+    'page callback' => 'blog_page',
+    'access arguments' => array('access content'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['blog/%'] = array(
+    'title' => t('My blog'),
+    'page arguments' => array(1),
+    'access arguments' => array('edit own blog'),
+  );
 
   return $items;
 }

=== modified file 'modules/blogapi/blogapi.module'
--- modules/blogapi/blogapi.module	2006-11-21 20:14:19 +0000
+++ modules/blogapi/blogapi.module	2006-12-14 22:27:19 +0000
@@ -551,35 +551,32 @@ function blogapi_admin_settings() {
   return system_settings_form($form);
 }
 
-function blogapi_menu($may_cache) {
-  $items = array();
+function blogapi_menu() {
+  $items['blogapi'] = array(
+    'title' => t('RSD'),
+    'page callback' => 'blogapi_blogapi',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/blogapi'] = array(
+    'title' => t('Blog APIs'),
+    'description' => t('Configure which content types and engines external blog clients can use.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('blogapi_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+
+  return $items;
+}
 
+function blogapi_start() {
   if (drupal_is_front_page()) {
     drupal_add_link(array('rel' => 'EditURI',
                           'type' => 'application/rsd+xml',
                           'title' => t('RSD'),
                           'href' => url('blogapi/rsd', NULL, NULL, TRUE)));
   }
-
-  if ($may_cache) {
-   $items[] = array(
-      'path' => 'blogapi',
-      'title' => t('RSD'),
-      'callback' => 'blogapi_blogapi',
-      'access' => user_access('access content'),
-      'type' => MENU_CALLBACK);
-    $items[] = array(
-      'path' => 'admin/settings/blogapi',
-      'title' => t('Blog APIs'),
-      'description' => t('Configure which content types and engines external blog clients can use.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('blogapi_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM
-    );
-  }
-
-  return $items;
 }
 
 function blogapi_blogapi() {

=== modified file 'modules/book/book.module'
--- modules/book/book.module	2006-12-29 07:41:44 +0000
+++ modules/book/book.module	2006-12-30 17:22:33 +0000
@@ -85,65 +85,57 @@ function book_link($type, $node = NULL, 
 /**
  * Implementation of hook_menu().
  */
-function book_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/content/book',
-      'title' => t('Books'),
-      'description' => t("Manage site's books and orphaned book pages."),
-      'callback' => 'book_admin',
-      'access' => user_access('administer nodes'));
-    $items[] = array(
-      'path' => 'admin/content/book/list',
-      'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array(
-      'path' => 'admin/content/book/orphan',
-      'title' => t('Orphan pages'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('book_admin_orphan'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 8);
-    $items[] = array(
-      'path' => 'book',
-      'title' => t('Books'),
-      'callback' => 'book_render',
-      'access' => user_access('access content'),
-      'type' => MENU_SUGGESTED_ITEM);
-    $items[] = array(
-      'path' => 'book/export',
-      'callback' => 'book_export',
-      'access' => user_access('access content'),
-      'type' => MENU_CALLBACK);
-  }
-  else {
-    // Add the CSS for this module
-    // We put this in !$may_cache so it's only added once per request
-    drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
-
-    // To avoid SQL overhead, check whether we are on a node page and whether the
-    // user is allowed to outline posts in books.
-    if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('outline posts in books')) {
-      // Only add the outline-tab for non-book pages:
-      $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.type != 'book'"), arg(1));
-      if (db_num_rows($result) > 0) {
-        $items[] = array(
-          'path' => 'node/'. arg(1) .'/outline',
-          'title' => t('Outline'),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('book_outline', arg(1)),
-          'access' => user_access('outline posts in books'),
-          'type' => MENU_LOCAL_TASK,
-          'weight' => 2);
-      }
-    }
-  }
+function book_menu() {
+  $items['admin/content/book'] = array(
+    'title' => t('Books'),
+    'description' => t("Manage site's books and orphaned book pages."),
+    'page callback' => 'book_admin',
+    'access arguments' => array('administer nodes'),
+  );
+  $items['admin/content/book/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/content/book/orphan'] = array(
+    'title' => t('Orphan pages'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('book_admin_orphan'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 8,
+  );
+  $items['book'] = array(
+    'title' => t('Books'),
+    'page callback' => 'book_render',
+    'access arguments' => array('access content'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['book/export'] = array(
+    'page callback' => 'book_export',
+    'type' => MENU_CALLBACK,
+  );
+  $items['node/%/outline'] = array(
+    'title' => t('Outline'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('book_outline', 1),
+    'access callback' => '_book_outline_access',
+    'access arguments' => array(1),
+    'map arguments' => array('node_load', 1),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
 
   return $items;
 }
 
+function _book_outline_access($node) {
+  // Only add the outline-tab for non-book pages:
+  return user_access('outline posts in books') && $node && ($node->type != 'book');
+}
+
+function book_start() {
+  drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
+}
+
 /**
  * Implementation of hook_block().
  *
@@ -256,9 +248,7 @@ function book_form(&$node) {
  * Implementation of function book_outline()
  * Handles all book outline operations.
  */
-function book_outline($nid) {
-  $node = node_load($nid);
-
+function book_outline($node) {
   $form['parent'] = array('#type' => 'select',
     '#title' => t('Parent'),
     '#default_value' => $node->parent,

=== modified file 'modules/comment/comment.module'
--- modules/comment/comment.module	2006-12-25 22:39:08 +0000
+++ modules/comment/comment.module	2006-12-30 17:22:36 +0000
@@ -140,70 +140,77 @@ function comment_help($section) {
    }
 }
 
+function _comment_view_access($node, $cid) {
+  return $node && $cid;
+}
+
 /**
  * Implementation of hook_menu().
  */
-function comment_menu($may_cache) {
-  $items = array();
+function comment_menu() {
+  $items['admin/content/comment'] = array(
+    'title' => t('Comments'),
+    'description' => t('List and edit site comments and the comment moderation queue.'),
+    'page callback' => 'comment_admin',
+    'access arguments' => array('administer comments'),
+  );
 
-  if ($may_cache) {
-    $access = user_access('administer comments');
-    $items[] = array(
-      'path' => 'admin/content/comment',
-      'title' => t('Comments'),
-      'description' => t('List and edit site comments and the comment moderation queue.'),
-      'callback' => 'comment_admin',
-      'access' => $access
-    );
+  // Tabs:
+  $items['admin/content/comment/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK, 
+    'weight' => -10,
+  );
 
-    // Tabs:
-    $items[] = array('path' => 'admin/content/comment/list', 'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-
-    // Subtabs:
-    $items[] = array('path' => 'admin/content/comment/list/new', 'title' => t('Published comments'),
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-    $items[] = array('path' => 'admin/content/comment/list/approval', 'title' => t('Approval queue'),
-      'callback' => 'comment_admin',
-      'callback arguments' => array('approval'),
-      'access' => $access,
-      'type' => MENU_LOCAL_TASK);
-
-    $items[] = array(
-      'path' => 'admin/content/comment/settings',
-      'title' => t('Settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('comment_admin_settings'),
-      'access' => $access,
-      'weight' => 10,
-      'type' => MENU_LOCAL_TASK);
-
-    $items[] = array('path' => 'comment/delete', 'title' => t('Delete comment'),
-      'callback' => 'comment_delete', 'access' => $access, 'type' => MENU_CALLBACK);
-
-    $access = user_access('post comments');
-    $items[] = array('path' => 'comment/edit', 'title' => t('Edit comment'),
-      'callback' => 'comment_edit',
-      'access' => $access, 'type' => MENU_CALLBACK);
-  }
-  else {
-    if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
-      $node = node_load(arg(2));
-      if ($node->nid) {
-        $items[] = array('path' => 'comment/reply', 'title' => t('Reply to comment'),
-          'callback' => 'comment_reply', 'access' => node_access('view', $node), 'type' => MENU_CALLBACK);
-      }
-    }
-    if ((arg(0) == 'node') && is_numeric(arg(1)) && is_numeric(arg(2))) {
-      $items[] = array(
-        'path' => ('node/'. arg(1) .'/'. arg(2)),
-        'title' => t('View'),
-        'callback' => 'node_page_view',
-        'callback arguments' => array(node_load(arg(1)), arg(2)),
-        'type' => MENU_CALLBACK,
-      );
-    }
-  }
+  // Subtabs:
+  $items['admin/content/comment/list/new'] = array(
+    'title' => t('Published comments'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/content/comment/list/approval'] = array(
+    'title' => t('Approval queue'),
+    'page arguments' => array('approval'),
+    'type' => MENU_LOCAL_TASK,
+  );
+
+  $items['admin/content/comment/settings'] = array(
+    'title' => t('Settings'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('comment_admin_settings'),
+    'weight' => 10,
+    'type' => MENU_LOCAL_TASK,
+  );
+
+  $items['comment/delete'] = array(
+    'title' => t('Delete comment'),
+    'page callback' => 'comment_delete',
+    'access arguments' => array('administer comments'),
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['comment/edit'] = array(
+    'title' => t('Edit comment'),
+    'page callback' => 'comment_edit',
+    'access arguments' => array('post comments'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['comment/reply'] = array(
+    'title' => t('Reply to comment'),
+    'page callback' => 'comment_reply',
+    'access callback' => 'node_access',
+    'access arguments' => array('view', 2),
+    'map arguments' => array('node_load', 2),
+    'type' => MENU_CALLBACK,
+  );
+  $items['node/%/%'] = array(
+    'title' => t('View'),
+    'page callback' => 'node_page_view',
+    'page arguments' => array(1, 2),
+    'access callback' => '_comment_view_access',
+    'access arguments' => array(1, 2),
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }

=== modified file 'modules/contact/contact.module'
--- modules/contact/contact.module	2006-12-04 10:43:34 +0000
+++ modules/contact/contact.module	2006-12-14 22:27:19 +0000
@@ -40,77 +40,68 @@ function contact_perm() {
 /**
  * Implementation of hook_menu().
  */
-function contact_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/build/contact',
-      'title' => t('Contact form'),
-      'description' => t('Create a system contact form and set up categories for the form to use.'),
-      'callback' => 'contact_admin_categories',
-      'access' => user_access('administer site configuration'),
-    );
-    $items[] = array('path' => 'admin/build/contact/list',
-      'title' => t('List'),
-      'callback' => 'contact_admin_categories',
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-    );
-    $items[] = array('path' => 'admin/build/contact/add',
-      'title' => t('Add category'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('contact_admin_edit'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 1,
-    );
-    $items[] = array('path' => 'admin/build/contact/edit',
-      'title' => t('Edit contact category'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('contact_admin_edit'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_CALLBACK,
-    );
-    $items[] = array('path' => 'admin/build/contact/delete',
-      'title' => t('Delete contact'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('contact_admin_delete'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_CALLBACK,
-    );
-    $items[] = array('path' => 'admin/build/contact/settings',
-      'title' => t('Settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('contact_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 2,
-    );
-    $items[] = array('path' => 'contact',
-      'title' => t('Contact'),
-      'callback' => 'contact_site_page',
-      'access' => user_access('access site-wide contact form'),
-      'type' => MENU_SUGGESTED_ITEM,
-    );
-  }
-  else {
-    if (arg(0) == 'user' && is_numeric(arg(1))) {
-      global $user;
-      $account = user_load(array('uid' => arg(1)));
-      if (($user->uid != $account->uid && $account->contact) || user_access('administer users')) {
-        $items[] = array('path' => 'user/'. arg(1) .'/contact',
-          'title' => t('Contact'),
-          'callback' => 'contact_user_page',
-          'type' => MENU_LOCAL_TASK,
-          'access' => $user->uid,
-          'weight' => 2,
-        );
-      }
-    }
-  }
-
+function contact_menu() {
+  $items['admin/build/contact'] = array(
+    'title' => t('Contact form'),
+    'description' => t('Create a system contact form and set up categories for the form to use.'),
+    'page callback' => 'contact_admin_categories',
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['admin/build/contact/list'] = array(
+    'title' => t('List'),
+    'page callback' => 'contact_admin_categories',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/build/contact/add'] = array(
+    'title' => t('Add category'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('contact_admin_edit'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 1,
+  );
+  $items['admin/build/contact/edit'] = array(
+    'title' => t('Edit contact category'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('contact_admin_edit'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/contact/delete'] = array(
+    'title' => t('Delete contact'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('contact_admin_delete'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/contact/settings'] = array(
+    'title' => t('Settings'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('contact_admin_settings'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
+  $items['contact'] = array(
+    'title' => t('Contact'),
+    'page callback' => 'contact_site_page',
+    'access arguments' => array('access site-wide contact form'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['user/%/contact'] = array(
+    'title' => t('Contact'),
+    'page callback' => 'contact_user_page',
+    'page arguments' => array(1),
+    'type' => MENU_LOCAL_TASK,
+    'access callback' => '_contact_user_tab_access',
+    'access arguments' => array(1),
+    'map arguments' => array('user_load', 1),
+    'weight' => 2,
+  );
   return $items;
 }
 
+function _contact_user_tab_access($account) {
+  global $user;
+  return $account && (($user->uid != $account->uid && $account->contact) || user_access('administer users'));
+}
+
 /**
  * Implementation of hook_user().
  *
@@ -299,26 +290,21 @@ function contact_admin_settings() {
 /**
  * Personal contact page.
  */
-function contact_user_page() {
+function contact_user_page($account) {
   global $user;
 
-  if ($account = user_load(array('uid' => arg(1)))) {
-    if (!valid_email_address($user->mail)) {
-      $output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
-    }
-    else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
-      $output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
-    }
-    else {
-      drupal_set_title($account->name);
-      $output = drupal_get_form('contact_mail_user', $account);
-    }
-
-    return $output;
+  if (!valid_email_address($user->mail)) {
+    $output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
+  }
+  else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
+    $output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
   }
   else {
-    drupal_not_found();
+    drupal_set_title($account->name);
+    $output = drupal_get_form('contact_mail_user', $account);
   }
+
+  return $output;
 }
 
 function contact_mail_user($recipient) {

=== modified file 'modules/drupal/drupal.module'
--- modules/drupal/drupal.module	2006-12-23 21:13:18 +0000
+++ modules/drupal/drupal.module	2006-12-30 17:22:34 +0000
@@ -336,28 +336,28 @@ function drupal_auth($username, $passwor
 /**
  * Implementation of hook_menu().
  */
-function drupal_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/settings/sites-registry',
-      'title' => t('Sites registry'),
-      'description' => t('Register with another Drupal site (drupal.org by default) for statistics sharing, or set up your server to be a central server for registrations.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('drupal_sites_registry_settings'),
-      'access' => user_access('administer site configuration'));
-    $items[] = array('path' => 'admin/settings/distributed-authentication',
-      'title' => t('Distributed authentication'),
-      'description' => t('Allow your site to accept logins from other Drupal sites such as drupal.org.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('drupal_distributed_authentication_settings'),
-      'access' => user_access('administer site configuration'));;
-
-    if (variable_get('drupal_authentication_service', 0)) {
-      $items[] = array('path' => 'drupal', 'title' => t('Drupal'),
-        'callback' => 'drupal_page_help', 'access' => TRUE,
-        'type' => MENU_SUGGESTED_ITEM
-      );
-    }
+function drupal_menu() {
+  $items['admin/settings/sites-registry'] = array(
+    'title' => t('Sites registry'),
+    'description' => t('Register with another Drupal site (drupal.org by default) for statistics sharing, or set up your server to be a central server for registrations.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('drupal_sites_registry_settings'),
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['admin/settings/distributed-authentication'] = array(
+    'title' => t('Distributed authentication'),
+    'description' => t('Allow your site to accept logins from other Drupal sites such as drupal.org.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('drupal_distributed_authentication_settings'),
+    'access arguments' => array('administer site configuration'),
+  );
+  if (variable_get('drupal_authentication_service', 0)) {
+    $items['drupal'] = array(
+      'title' => t('Drupal'),
+      'page callback' => 'drupal_page_help', 
+      'access callback' => TRUE,
+      'type' => MENU_SUGGESTED_ITEM,
+    );
   }
   return $items;
 }

=== modified file 'modules/filter/filter.module'
--- modules/filter/filter.module	2006-12-16 01:05:11 +0000
+++ modules/filter/filter.module	2006-12-30 17:03:00 +0000
@@ -50,85 +50,64 @@ function filter_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function filter_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/settings/filters',
-      'title' => t('Input formats'),
-      'description' => t('Configure how content input by users is filtered, including allowed HTML tags, PHP code tags. Also allows enabling of module-provided filters.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('filter_admin_overview'),
-      'access' => user_access('administer filters'),
-    );
-    $items[] = array('path' => 'admin/settings/filters/list',
-      'title' => t('List'),
-      'callback' => 'filter_admin_overview',
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-'access' => user_access('administer filters'),
-    );
-    $items[] = array('path' => 'admin/settings/filters/add',
-      'title' => t('Add input format'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('filter_admin_format_form'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 1,
-      'access' => user_access('administer filters'),
-    );
-    $items[] = array('path' => 'admin/settings/filters/delete',
-      'title' => t('Delete input format'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('filter_admin_delete'),
-      'type' => MENU_CALLBACK,
-      'access' => user_access('administer filters'),
-    );
-    $items[] = array('path' => 'filter/tips',
-      'title' => t('Compose tips'),
-      'callback' => 'filter_tips_long',
-      'access' => TRUE,
-      'type' => MENU_SUGGESTED_ITEM,
-    );
-  }
-  else {
-    if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'filters' && is_numeric(arg(3))) {
-      $formats = filter_formats();
-
-      if (isset($formats[arg(3)])) {
-        $items[] = array('path' => 'admin/settings/filters/'. arg(3),
-          'title' => t("!format input format", array('!format' => $formats[arg(3)]->name)),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('filter_admin_format_form', $formats[arg(3)]),
-          'type' => MENU_CALLBACK,
-          'access' => user_access('administer filters'),
-        );
-        $items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/list',
-          'title' => t('View'),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('filter_admin_format_form', $formats[arg(3)]),
-          'type' => MENU_DEFAULT_LOCAL_TASK,
-          'weight' => 0,
-          'access' => user_access('administer filters'),
-        );
-        $items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/configure',
-          'title' => t('Configure'),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('filter_admin_configure'),
-          'type' => MENU_LOCAL_TASK,
-          'weight' => 1,
-          'access' => user_access('administer filters'),
-        );
-        $items[] = array('path' => 'admin/settings/filters/'. arg(3) .'/order',
-          'title' => t('Rearrange'),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('filter_admin_order', 'format' => $formats[arg(3)]),
-          'type' => MENU_LOCAL_TASK,
-          'weight' => 2,
-          'access' => user_access('administer filters'),
-        );
-      }
-    }
-  }
+function filter_menu() {
+  $items['admin/settings/filters'] = array(
+    'title' => t('Input formats'),
+    'description' => t('Configure how content input by users is filtered, including allowed HTML tags, PHP code tags. Also allows enabling of module-provided filters.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('filter_admin_overview'),
+    'access arguments' => array('administer filters'),
+  );
+  $items['admin/settings/filters/list'] = array(
+    'title' => t('List'),
+    'page callback' => 'filter_admin_overview',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/settings/filters/add'] = array(
+    'title' => t('Add input format'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('filter_admin_format_form'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 1,
+  );
+  $items['admin/settings/filters/delete'] = array(
+    'title' => t('Delete input format'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('filter_admin_delete'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['filter/tips'] = array(
+    'title' => t('Compose tips'),
+    'page callback' => 'filter_tips_long',
+    'access callback' => TRUE,
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['admin/settings/filters/%'] = array(
+    'type' => MENU_CALLBACK,
+    'page arguments' => array('filter_admin_format_form', 3),
+    'access callback' => 'menu_access_and',
+    'access arguments' => array('administer filters', 3),
+    'map arguments' => array('filter_formats', 3, FALSE),
+  );
 
+  $items['admin/settings/filters/%/list'] = array(
+    'title' => t('View'),
+    'page arguments' => array('filter_admin_format_form', 3),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => 0,
+  );
+  $items['admin/settings/filters/%/configure'] = array(
+    'title' => t('Configure'),
+    'page arguments' => array('filter_admin_configure', 3),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 1,
+  );
+  $items['admin/settings/filters/%/order'] = array(
+    'title' => t('Rearrange'),
+    'page arguments' => array('filter_admin_order', 3),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
   return $items;
 }
 
@@ -459,6 +438,7 @@ function filter_admin_format_form($forma
     $group = '<p>'. t('These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.') .'</p>';
     $group .= $tiplist;
     $form['tips'] = array('#value' => '<h2>'. t('Formatting guidelines') .'</h2>'. $group);
+    drupal_set_title(t("!format input format", array('!format' => $format->name)));
   }
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
@@ -590,10 +570,8 @@ function filter_admin_order_submit($form
 /**
  * Menu callback; display settings defined by filters.
  */
-function filter_admin_configure() {
-  $format = arg(3);
-
-  $list = filter_list_format($format);
+function filter_admin_configure($format) {
+  $list = filter_list_format($format->format);
   $form = array();
   foreach ($list as $filter) {
     $form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format);
@@ -615,7 +593,7 @@ function filter_admin_configure() {
 /**
  * Retrieve a list of input formats.
  */
-function filter_formats() {
+function filter_formats($index = NULL) {
   global $user;
   static $formats;
 
@@ -644,6 +622,9 @@ function filter_formats() {
       $formats[$format->format] = $format;
     }
   }
+  if (isset($index)) {
+    return isset($formats[$index]) ? $formats[$index] : FALSE;
+  }
   return $formats;
 }
 
@@ -862,6 +843,7 @@ function filter_access($format) {
     return isset($formats[$format]);
   }
 }
+
 /**
  * @} End of "Filtering functions".
  */

=== modified file 'modules/forum/forum.module'
--- modules/forum/forum.module	2006-12-25 22:22:42 +0000
+++ modules/forum/forum.module	2006-12-30 17:22:32 +0000
@@ -31,71 +31,69 @@ function forum_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function forum_menu($may_cache) {
-  $items = array();
+function forum_menu() {
+  $items['node/add/forum'] = array(
+    'title' => t('Forum topic'),
+    'access arguments' => array('create forum topics'),
+  );
+  $items['forum'] = array(
+    'title' => t('Forums'),
+    'page callback' => 'forum_page',
+    'access arguments' => array('access content'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['admin/content/forum'] = array(
+    'title' => t('Forums'),
+    'description' => t('Control forums and their hierarchy and change forum settings.'),
+    'page callback' => 'forum_overview',
+    'access arguments' => array('administer forums'),
+  );
+  $items['admin/content/forum/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/content/forum/add/container'] = array(
+    'title' => t('Add container'),
+    'page callback' => 'forum_form_main',
+    'page arguments' => array('container'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/content/forum/add/forum'] = array(
+    'title' => t('Add forum'),
+    'page callback' => 'forum_form_main',
+    'page arguments' => array('forum'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/content/forum/settings'] = array(
+    'title' => t('Settings'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('forum_admin_settings'),
+    'weight' => 5,
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/content/forum/edit/%'] = array(
+    'page callback' => 'forum_form_main',
+    'map arguments' => array('_forum_get_term', 5, array()),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/content/forum/edit/container'] = array(
+    'title' => t('Edit container'),
+    'page arguments' => array('container', 5),
+  );
+  $items['admin/content/forum/edit/forum'] = array(
+    'title' => t('Edit forum'),
+    'page arguments' => array('forum', 5),
+  );
+  return $items;
+}
 
-  if ($may_cache) {
-    $items[] = array('path' => 'forum',
-      'title' => t('Forums'),
-      'callback' => 'forum_page',
-      'access' => user_access('access content'),
-      'type' => MENU_SUGGESTED_ITEM);
-    $items[] = array('path' => 'admin/content/forum',
-      'title' => t('Forums'),
-      'description' => t('Control forums and their hierarchy and change forum settings.'),
-      'callback' => 'forum_overview',
-      'access' => user_access('administer forums'),
-      'type' => MENU_NORMAL_ITEM);
-    $items[] = array('path' => 'admin/content/forum/list',
-      'title' => t('List'),
-      'access' => user_access('administer forums'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10);
-    $items[] = array('path' => 'admin/content/forum/add/container',
-      'title' => t('Add container'),
-      'callback' => 'forum_form_main',
-      'callback arguments' => array('container'),
-      'access' => user_access('administer forums'),
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/content/forum/add/forum',
-      'title' => t('Add forum'),
-      'callback' => 'forum_form_main',
-      'callback arguments' => array('forum'),
-      'access' => user_access('administer forums'),
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/content/forum/settings',
-      'title' => t('Settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('forum_admin_settings'),
-      'weight' => 5,
-      'access' => user_access('administer forums'),
-      'type' => MENU_LOCAL_TASK);
-  }
-  elseif (is_numeric(arg(5))) {
-    $term = taxonomy_get_term(arg(5));
-    // Check if this is a valid term.
-    if ($term) {
-      $items[] = array('path' => 'admin/content/forum/edit/container',
-        'title' => t('Edit container'),
-        'callback' => 'forum_form_main',
-        'callback arguments' => array('container', (array)$term),
-        'access' => user_access('administer forums'),
-        'type' => MENU_CALLBACK);
-      $items[] = array('path' => 'admin/content/forum/edit/forum',
-        'title' => t('Edit forum'),
-        'callback' => 'forum_form_main',
-        'callback arguments' => array('forum', (array)$term),
-        'access' => user_access('administer forums'),
-        'type' => MENU_CALLBACK);
-    }
-  }
-  else {
-    // Add the CSS for this module
-    // We put this in !$may_cache so it's only added once per request
-    drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
-  }
+function forum_start() {
+  drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
+}
 
-  return $items;
+function _forum_get_term($tid) {
+  return (array)taxonomy_get_term($tid);
 }
 
 /**

=== modified file 'modules/help/help.module'
--- modules/help/help.module	2006-12-23 22:06:05 +0000
+++ modules/help/help.module	2006-12-30 17:22:34 +0000
@@ -9,24 +9,20 @@
 /**
  * Implementation of hook_menu().
  */
-function help_menu($may_cache) {
-  $items = array();
+function help_menu() {
+  $items['admin/help'] = array(
+    'title' => t('Help'),
+    'page callback' => 'help_main',
+    'access arguments' => array('access administration pages'),
+    'weight' => 9,
+  );
 
-  if ($may_cache) {
-    $admin_access = user_access('access administration pages');
-
-    $items[] = array('path' => 'admin/help', 'title' => t('Help'),
-      'callback' => 'help_main',
-      'access' => $admin_access,
-      'weight' => 9);
-
-    foreach (module_implements('help', TRUE) as $module) {
-      $items[] = array('path' => 'admin/help/' . $module,
-        'title' => t($module),
-        'callback' => 'help_page',
-        'type' => MENU_CALLBACK,
-        'access' => $admin_access);
-    }
+  foreach (module_implements('help', TRUE) as $module) {
+    $items['admin/help/'. $module] = array(
+      'title' => t($module),
+      'page callback' => 'help_page',
+      'type' => MENU_CALLBACK,
+    );
   }
 
   return $items;

=== modified file 'modules/legacy/legacy.module'
--- modules/legacy/legacy.module	2006-11-21 20:14:19 +0000
+++ modules/legacy/legacy.module	2006-12-14 22:27:19 +0000
@@ -34,48 +34,65 @@ function legacy_help($section) {
  *
  * Registers menu paths used in earlier Drupal versions.
  */
-function legacy_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    // Map "taxonomy/page/or/52,97" to "taxonomy/term/52+97".
-    $items[] = array('path' => 'taxonomy/page', 'title' => t('Taxonomy'),
-      'callback' => 'legacy_taxonomy_page',
-      'access' => TRUE, 'type' => MENU_CALLBACK);
-
-    // Map "taxonomy/feed/or/52,97" to "taxonomy/term/52+97/0/feed".
-    $items[] = array('path' => 'taxonomy/feed', 'title' => t('Taxonomy'),
-      'callback' => 'legacy_taxonomy_feed',
-      'access' => TRUE, 'type' => MENU_CALLBACK);
-
-    // Map "blog/feed/52" to "blog/52/feed".
-    $items[] = array('path' => 'blog/feed', 'title' => t('Blog'),
-      'callback' => 'legacy_blog_feed',
-      'access' => TRUE, 'type' => MENU_CALLBACK);
-  }
-  else {
-    // Map "node/view/52" to "node/52".
-    $items[] = array('path' => 'node/view', 'title' => t('View'),
-      'callback' => 'drupal_goto',
-      'callback arguments' => array('node/'. arg(2), NULL, NULL),
-      'access' => TRUE, 'type' => MENU_CALLBACK);
-
-    // Map "book/view/52" to "node/52".
-    $items[] = array('path' => 'book/view', 'title' => t('View'),
-      'callback' => 'drupal_goto',
-      'callback arguments' => array('node/'. arg(2), NULL, NULL),
-      'access' => TRUE, 'type' => MENU_CALLBACK);
-
-    // Map "user/view/52" to "user/52".
-    $items[] = array('path' => 'user/view', 'title' => t('View'),
-      'callback' => 'drupal_goto',
-      'callback arguments' => array('user/'. arg(2), NULL, NULL),
-      'access' => TRUE, 'type' => MENU_CALLBACK);
-  }
+function legacy_menu() {
+  // Map "taxonomy/page/or/52,97" to "taxonomy/term/52+97".
+  $items['taxonomy/page'] = array(
+    'title' => t('Taxonomy'),
+    'page callback' => 'legacy_taxonomy_page',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
+  // Map "taxonomy/feed/or/52,97" to "taxonomy/term/52+97/0/feed".
+  $items['taxonomy/feed'] = array(
+    'title' => t('Taxonomy'),
+    'page callback' => 'legacy_taxonomy_feed',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
+  // Map "blog/feed/52" to "blog/52/feed".
+  $items['blog/feed'] = array(
+    'title' => t('Blog'),
+    'page callback' => 'legacy_blog_feed',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
+  // Map "node/view/52" to "node/52".
+  $items['node/view'] = array(
+    'title' => t('View'),
+    'page callback' => '_legacy_goto',
+    'page arguments' => array('node', 2),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
+  // Map "book/view/52" to "node/52".
+  $items['book/view'] = array(
+    'title' => t('View'),
+    'page callback' => '_legacy_goto',
+    'page arguments' => array('node', 2),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+
+  // Map "user/view/52" to "user/52".
+  $items['user/view'] = array(
+    'title' => t('View'),
+    'page callback' => 'drupal_goto',
+    'page arguments' => array('user', 2),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
 
+function _legacy_goto($type, $arg) {
+  drupal_goto("$type/$arg", NULL, NULL);
+}
+
 /**
  * Menu callback; redirects users to new taxonomy page paths.
  */

=== modified file 'modules/locale/locale.module'
--- modules/locale/locale.module	2006-12-27 13:11:59 +0000
+++ modules/locale/locale.module	2006-12-30 17:22:34 +0000
@@ -41,82 +41,73 @@ function locale_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function locale_menu($may_cache) {
-  $items = array();
-  $access = user_access('administer locales');
-
-  if ($may_cache) {
-    // Main admin menu item
-    $items[] = array('path' => 'admin/settings/locale',
-      'title' => t('Localization'),
-      'description' => t('Configure site localization and user interface translation.'),
-      'callback' => 'locale_admin_manage',
-      'access' => $access);
-
-    // Top level tabs
-    $items[] = array('path' => 'admin/settings/locale/language',
-      'title' => t('Manage languages'),
-      'access' => $access,
-      'weight' => -10,
-      'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array('path' => 'admin/settings/locale/string/search',
-      'title' => t('Manage strings'),
-      'callback' => 'locale_string_search',
-      'access' => $access,
-      'weight' => 10,
-      'type' => MENU_LOCAL_TASK);
-
-    // Manage languages subtabs
-    $items[] = array('path' => 'admin/settings/locale/language/overview',
-      'title' => t('List'),
-      'callback' => 'locale_admin_manage',
-      'access' => $access,
-      'weight' => 0,
-      'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array('path' => 'admin/settings/locale/language/add',
-      'title' => t('Add language'),
-      'callback' => 'locale_admin_manage_add',
-      'access' => $access,
-      'weight' => 5,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/settings/locale/language/import',
-      'title' => t('Import'),
-      'callback' => 'locale_admin_import',
-      'access' => $access,
-      'weight' => 10,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/settings/locale/language/export',
-      'title' => t('Export'),
-      'callback' => 'locale_admin_export',
-      'access' => $access,
-      'weight' => 20,
-      'type' => MENU_LOCAL_TASK);
-
-    // Language related callbacks
-    $items[] = array('path' => 'admin/settings/locale/language/delete',
-      'title' => t('Confirm'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('locale_admin_manage_delete_form'),
-      'access' => $access,
-      'type' => MENU_CALLBACK);
-  }
-  else {
-    if (is_numeric(arg(5))) {
-      // String related callbacks
-      $items[] = array('path' => 'admin/settings/locale/string/edit/'. arg(5),
-        'title' => t('Edit string'),
-        'callback' => 'drupal_get_form',
-        'callback arguments' => array('locale_admin_string_edit', arg(5)),
-        'access' => $access,
-        'type' => MENU_CALLBACK);
-      $items[] = array('path' => 'admin/settings/locale/string/delete/'. arg(5),
-        'title' => t('Delete string'),
-        'callback' => 'locale_admin_string_delete',
-        'callback arguments' => array(arg(5)),
-        'access' => $access,
-        'type' => MENU_CALLBACK);
-    }
-  }
+function locale_menu() {
+  // Main admin menu item
+  $items['admin/settings/locale'] = array(
+    'title' => t('Localization'),
+    'description' => t('Configure site localization and user interface translation.'),
+    'page callback' => 'locale_admin_manage',
+    'access arguments' => array('administer locales'),
+  );
+
+  // Top level tabs
+  $items['admin/settings/locale/language'] = array(
+    'title' => t('Manage languages'),
+    'weight' => -10,
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/settings/locale/string/search'] = array(
+    'title' => t('Manage strings'),
+    'page callback' => 'locale_string_search',
+    'weight' => 10,
+    'type' => MENU_LOCAL_TASK,
+  );
+
+  // Manage languages subtabs
+  $items['admin/settings/locale/language/overview'] = array(
+    'title' => t('List'),
+    'weight' => 0,
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/settings/locale/language/add'] = array(
+    'title' => t('Add language'),
+    'page callback' => 'locale_admin_manage_add',
+    'weight' => 5,
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/settings/locale/language/import'] = array(
+    'title' => t('Import'),
+    'page callback' => 'locale_admin_import',
+    'weight' => 10,
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/settings/locale/language/export'] = array(
+    'title' => t('Export'),
+    'page callback' => 'locale_admin_export',
+    'weight' => 20,
+    'type' => MENU_LOCAL_TASK,
+  );
+
+  // Language related callbacks
+  $items['admin/settings/locale/language/delete'] = array(
+    'title' => t('Confirm'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('locale_admin_manage_delete_form'),
+    'type' => MENU_CALLBACK,
+  );
+  // String related callbacks
+  $items['admin/settings/locale/string/edit/%'] = array(
+    'title' => t('Edit string'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('locale_admin_string_edit', 5),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/locale/string/delete/%'] = array(
+    'title' => t('Delete string'),
+    'page callback' => 'locale_admin_string_delete',
+    'page arguments' => array(5),
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }

=== modified file 'modules/node/node.module'
--- modules/node/node.module	2006-12-29 21:25:36 +0000
+++ modules/node/node.module	2006-12-30 17:22:33 +0000
@@ -1054,175 +1054,163 @@ function node_link($type, $node = NULL, 
   return $links;
 }
 
+function _node_revision_access($node) {
+  return (user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) > 1;
+}
+
 /**
  * Implementation of hook_menu().
  */
-function node_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/content',
-      'title' => t('Content management'),
-      'description' => t("Manage your site's content."),
-      'position' => 'left',
-      'weight' => -10,
-      'callback' => 'system_admin_menu_block_page',
-      'access' => user_access('administer site configuration'),
-    );
+function node_menu() {
+  $items['admin/content'] = array(
+    'title' => t('Content management'),
+    'description' => t("Manage your site's content."),
+    'position' => 'left',
+    'weight' => -10,
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('administer site configuration'),
+  );
 
-    $items[] = array(
-      'path' => 'admin/content/node',
-      'title' => t('Content'),
-      'description' => t("View, edit, and delete your site's content."),
-      'callback' => 'node_admin_content',
-      'access' => user_access('administer nodes')
-    );
+  $items['admin/content/node'] = array(
+    'title' => t('Content'),
+    'description' => t("View, edit, and delete your site's content."),
+    'page callback' => 'node_admin_content',
+    'access arguments' => array('administer nodes'),
+  );
 
-    $items[] = array('path' => 'admin/content/node/overview', 'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
+  $items['admin/content/node/overview'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
 
-    if (module_exists('search')) {
-      $items[] = array('path' => 'admin/content/search', 'title' => t('Search content'),
-        'description' => t('Search content by keyword.'),
-        'callback' => 'node_admin_search',
-        'access' => user_access('administer nodes'),
-        'type' => MENU_NORMAL_ITEM);
-    }
-
-    $items[] = array(
-      'path' => 'admin/content/node-settings',
-      'title' => t('Post settings'),
-      'description' => t('Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('node_configure'),
-      'access' => user_access('administer nodes')
-    );
-    $items[] = array(
-      'path' => 'admin/content/node-settings/rebuild',
-      'title' => t('rebuild permissions'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('node_configure_rebuild_confirm'),
-      'access' => user_access('administer nodes'),
-      'type' => MENU_CALLBACK);
-
-    $items[] = array(
-      'path' => 'admin/content/types',
-      'title' => t('Content types'),
-      'description' => t('Manage posts by content type, including default status, front page promotion, etc.'),
-      'callback' => 'node_overview_types',
-      'access' => user_access('administer content types'),
-    );
-    $items[] = array(
-      'path' => 'admin/content/types/list',
-      'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10,
-    );
-    $items[] = array(
-      'path' => 'admin/content/types/add',
-      'title' => t('Add content type'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('node_type_form'),
-      'type' => MENU_LOCAL_TASK,
+  if (module_exists('search')) {
+    $items['admin/content/search'] = array(
+      'title' => t('Search content'),
+      'description' => t('Search content by keyword.'),
+      'page callback' => 'node_admin_search',
+      'access arguments' => array('administer nodes'),
     );
-    $items[] = array('path' => 'node',
-      'title' => t('Content'),
-      'callback' => 'node_page_default',
-      'access' => user_access('access content'),
-      'type' => MENU_MODIFIABLE_BY_ADMIN);
-    $items[] = array('path' => 'node/add',
-      'title' => t('Create content'),
-      'callback' => 'node_add',
-      'access' => user_access('access content'),
-      'type' => MENU_ITEM_GROUPING,
-      'weight' => 1);
-    $items[] = array('path' => 'rss.xml', 'title' => t('RSS feed'),
-      'callback' => 'node_feed',
-      'access' => user_access('access content'),
-      'type' => MENU_CALLBACK);
-
-    foreach (node_get_types() as $type) {
-      if (function_exists($type->module .'_form')) {
-        $name = check_plain($type->name);
-        $type_url_str = str_replace('_', '-', $type->type);
-        $items[] = array(
-          'path' => 'node/add/'. $type_url_str,
-          'title' => drupal_ucfirst(t($name)),
-          'access' => node_access('create', $type->type),
-        );
-      }
-    }
   }
-  else {
-    // Add the CSS for this module
-    // We put this in !$may_cache so it's only added once per request
-    drupal_add_css(drupal_get_path('module', 'node') .'/node.css');
-
-    if (arg(0) == 'node' && is_numeric(arg(1))) {
-      $node = node_load(arg(1));
-      if ($node->nid) {
-        $items[] = array('path' => 'node/'. arg(1), 'title' => t('View'),
-          'callback' => 'node_page_view',
-          'callback arguments' => array($node),
-          'access' => node_access('view', $node),
-          'type' => MENU_CALLBACK);
-        $items[] = array('path' => 'node/'. arg(1) .'/view', 'title' => t('View'),
-          'type' => MENU_DEFAULT_LOCAL_TASK,
-          'weight' => -10);
-        $items[] = array('path' => 'node/'. arg(1) .'/edit', 'title' => t('Edit'),
-          'callback' => 'node_page_edit',
-          'callback arguments' => array($node),
-          'access' => node_access('update', $node),
-          'weight' => 1,
-          'type' => MENU_LOCAL_TASK);
-        $items[] = array('path' => 'node/'. arg(1) .'/delete', 'title' => t('Delete'),
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array('node_delete_confirm', $node),
-          'access' => node_access('delete', $node),
-          'weight' => 1,
-          'type' => MENU_CALLBACK);
-        $revisions_access = ((user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', arg(1))) > 1);
-        $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('Revisions'),
-          'callback' => 'node_revisions',
-          'access' => $revisions_access,
-          'weight' => 2,
-          'type' => MENU_LOCAL_TASK);
-      }
-    }
 
-    // Content type configuration.
-    if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types') {
-      include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
-
-      if (arg(3) != NULL) {
-        $type_name = arg(3);
-        $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
-        $type = node_get_types('type', $type_name);
-
-        if (!empty($type)) {
-          $type->name = check_plain($type->name);
-          $type_url_str = str_replace('_', '-', $type->type);
-
-          $items[] = array(
-            'path' => 'admin/content/types/'. $type_url_str,
-            'title' => t($type->name),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('node_type_form', $type),
-            'type' => MENU_CALLBACK,
-          );
-          $items[] = array(
-            'path' => 'admin/content/types/'. $type_url_str .'/delete',
-            'title' => t('Delete'),
-            'callback' => 'drupal_get_form',
-            'callback arguments' => array('node_type_delete_confirm', $type),
-            'type' => MENU_CALLBACK,
-          );
-        }
-      }
+  $items['admin/content/node-settings'] = array(
+    'title' => t('Post settings'),
+    'description' => t('Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('node_configure'),
+    'access arguments' => array('administer nodes'),
+  );
+  $items['admin/content/node-settings/rebuild'] = array(
+    'title' => t('rebuild permissions'),
+    'page arguments' => array('node_configure_rebuild_confirm'),
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['admin/content/types'] = array(
+    'title' => t('Content types'),
+    'description' => t('Manage posts by content type, including default status, front page promotion, etc.'),
+    'page callback' => 'node_overview_types',
+    'access arguments' => array('administer content types'),
+  );
+  $items['admin/content/types/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/content/types/add'] = array(
+    'title' => t('Add content type'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('node_type_form'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['node'] = array(
+    'title' => t('Content'),
+    'page callback' => 'node_page_default',
+    'access arguments' => array('access content'),
+    'type' => MENU_MODIFIABLE_BY_ADMIN,
+  );
+  $items['node/add'] = array(
+    'title' => t('Create content'),
+    'page callback' => 'node_add',
+    'access callback' => 'user_access',
+    'access arguments' => array('access content'),
+    'type' => MENU_ITEM_GROUPING,
+    'weight' => 1,
+  );
+  $items['rss.xml'] = array(
+    'title' => t('RSS feed'),
+    'page callback' => 'node_feed',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  foreach (node_get_types() as $type) {
+    if (function_exists($type->module .'_form')) {
+      $name = check_plain($type->name);
+      $type_url_str = str_replace('_', '-', $type->type);
+      $items['node/add/'. $type_url_str] = array(
+        'title' => drupal_ucfirst(t($name)),
+        'page arguments' => array(2),
+        'access callback' => 'node_access',
+        'access arguments' => array('create', $type->type),
+      );
+      $items['admin/content/types/'. $type_url_str] = array(
+        'title' => t($type->name),
+        'page callback' => 'drupal_get_form',
+        'page arguments' => array('node_type_form', $type),
+        'type' => MENU_CALLBACK,
+      );
+      $items['admin/content/types/'. $type_url_str .'/delete'] = array(
+        'title' => t('Delete'),
+        'page arguments' => array('node_type_delete_confirm', $type),
+        'type' => MENU_CALLBACK,
+      );
+
     }
   }
+  $items['node/%'] = array(
+    'title' => t('View'),
+    'page callback' => 'node_page_view',
+    'page arguments' => array(1),
+    'access callback' => 'node_access',
+    'access arguments' => array('view', 1),
+    'map arguments' => array('node_load', 1),
+    'type' => MENU_CALLBACK);
+  $items['node/%/view'] = array(
+    'title' => t('View'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10);
+  $items['node/%/edit'] = array(
+    'title' => t('Edit'),
+    'page callback' => 'node_page_edit',
+    'page arguments' => array(1),
+    'access arguments' => array('update', 1),
+    'weight' => 1,
+    'type' => MENU_LOCAL_TASK);
+  $items['node/%/delete'] = array(
+    'title' => t('Delete'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('node_delete_confirm'),
+    'access arguments' => array('delete', 1),
+    'weight' => 1,
+    'type' => MENU_CALLBACK);
+  $items['node/%/revisions'] = array(
+    'title' => t('Revisions'),
+    'page callback' => 'node_revisions',
+    'access callback' => '_node_revision_access',
+    'access arguments' => array(1),
+    'weight' => 2,
+    'type' => MENU_LOCAL_TASK,
+  );
   return $items;
 }
 
+function node_start() {
+  if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'types') {
+    include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
+  }
+  drupal_add_css(drupal_get_path('module', 'node') .'/node.css');
+}
+
 function node_last_changed($nid) {
   $node = db_fetch_object(db_query('SELECT changed FROM {node} WHERE nid = %d', $nid));
   return ($node->changed);
@@ -2609,9 +2597,12 @@ function node_search_validate($form_id, 
  * @return
  *   TRUE if the operation may be performed.
  */
-function node_access($op, $node = NULL) {
+function node_access($op, $node) {
   global $user;
 
+  if (!$node) {
+    return FALSE;
+  }
   // Convert the node to an object if necessary:
   if ($op != 'create') {
     $node = (object)$node;

=== modified file 'modules/path/path.module'
--- modules/path/path.module	2006-12-18 11:16:51 +0000
+++ modules/path/path.module	2006-12-30 17:03:01 +0000
@@ -35,32 +35,37 @@ function path_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function path_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/build/path', 'title' => t('URL aliases'),
-      'description' => t('Change your site\'s URL paths by aliasing them.'),
-      'callback' => 'path_admin',
-      'access' => user_access('administer url aliases'));
-    $items[] = array('path' => 'admin/build/path/edit', 'title' => t('Edit alias'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('path_admin_edit'),
-      'access' => user_access('administer url aliases'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/build/path/delete', 'title' => t('Delete alias'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('path_admin_delete_confirm'),
-      'access' => user_access('administer url aliases'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/build/path/list', 'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-    $items[] = array('path' => 'admin/build/path/add', 'title' => t('Add alias'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('path_admin_edit'),
-      'access' => user_access('administer url aliases'),
-      'type' => MENU_LOCAL_TASK);
-  }
+function path_menu() {
+  $items['admin/build/path'] = array(
+    'title' => t('URL aliases'),
+    'description' => t('Change your site\'s URL paths by aliasing them.'),
+    'page callback' => 'path_admin',
+    'access arguments' => array('administer url aliases'),
+  );
+  $items['admin/build/path/edit'] = array(
+    'title' => t('Edit alias'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('path_admin_edit'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/path/delete'] = array(
+    'title' => t('Delete alias'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('path_admin_delete_confirm'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/path/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/build/path/add'] = array(
+    'title' => t('Add alias'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('path_admin_edit'),
+    'access arguments' => array('administer url aliases'),
+    'type' => MENU_LOCAL_TASK,
+  );
 
   return $items;
 }

=== modified file 'modules/poll/poll.module'
--- modules/poll/poll.module	2006-12-25 09:48:42 +0000
+++ modules/poll/poll.module	2006-12-30 17:22:34 +0000
@@ -227,56 +227,50 @@ function poll_insert($node) {
 /**
  * Implementation of hook_menu().
  */
-function poll_menu($may_cache) {
-  $items = array();
+function poll_menu() {
+  $items['poll'] = array(
+    'title' => t('Polls'),
+    'page callback' => 'poll_page',
+    'access arguments' => array('access content'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
 
-  if ($may_cache) {
-    $items[] = array('path' => 'poll', 'title' => t('Polls'),
-      'callback' => 'poll_page',
-      'access' => user_access('access content'),
-      'type' => MENU_SUGGESTED_ITEM);
-
-    $items[] = array('path' => 'poll/vote',
-      'title' => t('Vote'),
-      'callback' => 'poll_vote',
-      'access' => user_access('vote on polls'),
-      'type' => MENU_CALLBACK);
-
-    $items[] = array('path' => 'poll/cancel',
-      'title' => t('Cancel'),
-      'callback' => 'poll_cancel',
-      'access' => user_access('cancel own vote'),
-      'type' => MENU_CALLBACK);
-  }
-  else {
-    // Add the CSS for this module
-    // We put this in !$may_cache so it's only added once per request
-    drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css');
-
-    if (arg(0) == 'node' && is_numeric(arg(1))) {
-      $node = node_load(arg(1));
-      if ($node->type == 'poll') {
-        $items[] = array('path' => 'node/'. arg(1) .'/votes',
-          'title' => t('Votes'),
-          'callback' => 'poll_votes',
-          'access' => user_access('inspect all votes'),
-          'weight' => 3,
-          'type' => MENU_LOCAL_TASK);
-      }
-      if ($node->type == 'poll' && $node->allowvotes) {
-        $items[] = array('path' => 'node/'. arg(1) .'/results',
-          'title' => t('Results'),
-          'callback' => 'poll_results',
-          'access' => user_access('access content'),
-          'weight' => 3,
-          'type' => MENU_LOCAL_TASK);
-      }
-    }
-  }
+  $items['poll/vote'] = array(
+    'title' => t('Vote'),
+    'page callback' => 'poll_vote',
+    'access arguments' => array('vote on polls'),
+    'type' => MENU_CALLBACK,
+  );
 
+  $items['poll/cancel'] = array(
+    'title' => t('Cancel'),
+    'page callback' => 'poll_cancel',
+    'access arguments' => array('cancel own vote'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['node/%/votes'] = array(
+    'title' => t('Votes'),
+    'page callback' => 'poll_votes',
+    'access callback' => '_poll_menu_access',
+    'access arguments' => array(1, 'inspect all votes'),
+    'weight' => 3,
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['node/%/results'] = array(
+    'title' => t('Results'),
+    'page callback' => 'poll_results',
+    'access callback' => '_poll_menu_access',
+    'access arguments' => array(1, 'access content', TRUE),
+    'weight' => 3,
+    'type' => MENU_LOCAL_TASK,
+  );
   return $items;
 }
 
+function poll_start() {
+  drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css');
+}
+
 /**
  * Implementation of hook_load().
  */

=== modified file 'modules/profile/profile.module'
--- modules/profile/profile.module	2006-12-27 12:55:52 +0000
+++ modules/profile/profile.module	2006-12-30 17:22:35 +0000
@@ -54,45 +54,47 @@ function profile_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function profile_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'profile',
-      'title' => t('User list'),
-      'callback' => 'profile_browse',
-      'access' => user_access('access user profiles'),
-      'type' => MENU_SUGGESTED_ITEM);
-    $items[] = array('path' => 'admin/user/profile',
-      'title' => t('Profiles'),
-      'description' => t('Create customizable fields for your users.'),
-      'callback' => 'profile_admin_overview');
-    $items[] = array('path' => 'admin/user/profile/add',
-      'title' => t('Add field'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('profile_field_form'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/user/profile/autocomplete',
-      'title' => t('Profile category autocomplete'),
-      'callback' => 'profile_admin_settings_autocomplete',
-      'access' => user_access('administer users'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/user/profile/edit',
-      'title' => t('Edit field'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('profile_field_form'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/user/profile/delete',
-      'title' => t('Delete field'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('profile_field_delete'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'profile/autocomplete', 'title' => t('Profile autocomplete'),
-      'callback' => 'profile_autocomplete',
-      'access' => 1,
-      'type' => MENU_CALLBACK);
-  }
-
+function profile_menu() {
+  $items['profile'] = array(
+    'title' => t('User list'),
+    'page callback' => 'profile_browse',
+    'access arguments' => array('access user profiles'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['admin/user/profile'] = array(
+    'title' => t('Profiles'),
+    'description' => t('Create customizable fields for your users.'),
+    'page callback' => 'profile_admin_overview',
+  );
+  $items['admin/user/profile/add'] = array(
+    'title' => t('Add field'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('profile_field_form'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/user/profile/autocomplete'] = array(
+    'title' => t('Profile category autocomplete'),
+    'page callback' => 'profile_admin_settings_autocomplete',
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/user/profile/edit'] = array(
+    'title' => t('Edit field'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('profile_field_form'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/user/profile/delete'] = array(
+    'title' => t('Delete field'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('profile_field_delete'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['profile/autocomplete'] = array(
+    'title' => t('Profile autocomplete'),
+    'page callback' => 'profile_autocomplete',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 

=== modified file 'modules/search/search.module'
--- modules/search/search.module	2006-12-19 09:44:53 +0000
+++ modules/search/search.module	2006-12-30 17:10:18 +0000
@@ -136,51 +136,64 @@ function search_block($op = 'list', $del
 /**
  * Implementation of hook_menu().
  */
-function search_menu($may_cache) {
-  $items = array();
+function search_menu() {
+  $items['search'] = array(
+    'title' => t('Search'),
+    'page callback' => 'search_view',
+    'page arguments' => array('node'),
+    'access arguments' => array('search content'),
+    'type' => MENU_SUGGESTED_ITEM,
+  );
+  $items['admin/settings/search'] = array(
+    'title' => t('Search settings'),
+    'description' => t('Configure relevance settings for search and other indexing options'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('search_admin_settings'),
+    'access arguments' => array('administer search'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  $items['admin/settings/search/wipe'] = array(
+    'title' => t('Clear index'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('search_wipe_confirm'),
+    'access arguments' => array('administer search'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/logs/search'] = array(
+    'title' => t('Top search phrases'),
+    'description' => t('View most popular search phrases.'),
+    'page callback' => 'watchdog_top',
+    'page arguments' => array('search'),
+  );
 
-  if ($may_cache) {
-    $items[] = array('path' => 'search',
-      'title' => t('Search'),
-      'callback' => 'search_view',
-      'callback arguments' => array('node'),
-      'access' => user_access('search content'),
-      'type' => MENU_SUGGESTED_ITEM);
-    $items[] = array('path' => 'admin/settings/search',
-      'title' => t('Search settings'),
-      'description' => t('Configure relevance settings for search and other indexing options'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('search_admin_settings'),
-      'access' => user_access('administer search'),
-      'type' => MENU_NORMAL_ITEM);
-    $items[] = array('path' => 'admin/settings/search/wipe',
-      'title' => t('Clear index'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('search_wipe_confirm'),
-      'access' => user_access('administer search'),
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/logs/search', 'title' => t('Top search phrases'),
-      'description' => t('View most popular search phrases.'),
-      'callback' => 'watchdog_top',
-      'callback arguments' => array('search'));
-  }
-  else if (arg(0) == 'search') {
-    // To remember the user's search keywords when switching across tabs,
-    // we dynamically add the keywords to the search tabs' paths.
-    $keys = search_get_keys();
-    $keys = strlen($keys) ? '/'. $keys : '';
+  foreach (module_list() as $name) {
+    if (module_hook($name, 'search') && $title = module_invoke($name, 'search', 'name')) {
+      $items['search/'. $name] = array(
+        'title' => $title,
+        'page callback' => 'search_view',
+        'page arguments' => array($name),
+        'access arguments' => array('search content'),
+        'type' => MENU_LOCAL_TASK,
+      );
+    }
+  }
+  return $items;
+}
+
+function search_start() {
+  // This code is not necessary for phase1, only for phase2, just I did not want to lose it.
+  // To remember the user's search keywords when switching across tabs,
+  // we dynamically add the keywords to the search tabs' paths.
+  if (arg(0) == 'search' && ($keys = search_get_keys())) {
+    $keys = '/'. $keys;
     foreach (module_list() as $name) {
       if (module_hook($name, 'search') && $title = module_invoke($name, 'search', 'name')) {
-        $items[] = array('path' => 'search/'. $name . $keys, 'title' => $title,
-          'callback' => 'search_view',
-          'callback arguments' => array($name),
-          'access' => user_access('search content'),
-          'type' => MENU_LOCAL_TASK);
+        $item = menu_get_item('search/'. $name);
+        menu_set_item('search/'. $name . $keys, $item);
+        menu_set_item('search/'. $name, FALSE);
       }
     }
   }
-
-  return $items;
 }
 
 /**

=== modified file 'modules/statistics/statistics.module'
--- modules/statistics/statistics.module	2006-12-30 07:53:31 +0000
+++ modules/statistics/statistics.module	2006-12-30 17:22:35 +0000
@@ -99,74 +99,63 @@ function statistics_link($type, $node = 
 /**
  * Implementation of hook_menu().
  */
-function statistics_menu($may_cache) {
-  $items = array();
-
-  $access = user_access('access statistics');
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/logs/hits',
-      'title' => t('Recent hits'),
-      'description' => t('View pages that have recently been visited.'),
-      'callback' => 'statistics_recent_hits',
-      'access' => $access);
-    $items[] = array(
-      'path' => 'admin/logs/pages',
-      'title' => t('Top pages'),
-      'description' => t('View pages that have been hit frequently.'),
-      'callback' => 'statistics_top_pages',
-      'access' => $access,
-      'weight' => 1);
-    $items[] = array(
-      'path' => 'admin/logs/visitors',
-      'title' => t('Top visitors'),
-      'description' => t('View visitors that hit many pages.'),
-      'callback' => 'statistics_top_visitors',
-      'access' => $access,
-      'weight' => 2);
-    $items[] = array(
-      'path' => 'admin/logs/referrers',
-      'title' => t('Top referrers'),
-      'description' => t('View top referrers.'),
-      'callback' => 'statistics_top_referrers',
-      'access' => $access);
-    $items[] = array(
-      'path' => 'admin/logs/access',
-      'title' => t('Details'),
-      'description' => t('View access log.'),
-      'callback' => 'statistics_access_log',
-      'access' => $access,
-      'type' => MENU_CALLBACK);
-    $items[] = array(
-      'path' => 'admin/logs/settings',
-      'title' => t('Access log settings'),
-      'description' => t('Control details about what and how your site logs.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('statistics_access_logging_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-      'weight' => 3);
-  }
-  else {
-    if (arg(0) == 'user' && is_numeric(arg(1)) && variable_get('statistics_enable_access_log', 0)) {
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/track/navigation',
-        'title' => t('Track page visits'),
-        'callback' => 'statistics_user_tracker',
-        'access' => $access,
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 2);
-    }
-    if (arg(0) == 'node' && is_numeric(arg(1)) && variable_get('statistics_enable_access_log', 0)) {
-      $items[] = array(
-        'path' => 'node/'. arg(1) .'/track',
-        'title' => t('Track'),
-        'callback' => 'statistics_node_tracker',
-        'access' => $access,
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 2);
-    }
-  }
+function statistics_menu() {
+  $items['admin/logs/hits'] = array(
+    'title' => t('Recent hits'),
+    'description' => t('View pages that have recently been visited.'),
+    'page callback' => 'statistics_recent_hits',
+    'access arguments' => array('access statistics'),
+  );
+  $items['admin/logs/pages'] = array(
+    'title' => t('Top pages'),
+    'description' => t('View pages that have been hit frequently.'),
+    'page callback' => 'statistics_top_pages',
+    'access arguments' => array('access statistics'),
+    'weight' => 1,
+  );
+  $items['admin/logs/visitors'] = array(
+    'title' => t('Top visitors'),
+    'description' => t('View visitors that hit many pages.'),
+    'page callback' => 'statistics_top_visitors',
+    'access arguments' => array('access statistics'),
+    'weight' => 2,
+  );
+  $items['admin/logs/referrers'] = array(
+    'title' => t('Top referrers'),
+    'description' => t('View top referrers.'),
+    'page callback' => 'statistics_top_referrers',
+    'access arguments' => array('access statistics'),
+  );
+  $items['admin/logs/access'] = array(
+    'title' => t('Details'),
+    'description' => t('View access log.'),
+    'page callback' => 'statistics_access_log',
+    'access arguments' => array('access statistics'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/logs/settings'] = array(
+    'title' => t('Access log settings'),
+    'description' => t('Control details about what and how your site logs.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('statistics_access_logging_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 3,
+  );
+  $items['user/%/track/navigation'] = array(
+    'title' => t('Track page visits'),
+    'page callback' => 'statistics_user_tracker',
+    'access arguments' => array('access statistics'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
+  $items['node/%/track'] = array(
+    'title' => t('Track'),
+    'page callback' => 'statistics_node_tracker',
+    'access arguments' => array('access statistics'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
 
   return $items;
 }

=== modified file 'modules/system/system.install'
--- modules/system/system.install	2006-12-30 08:47:49 +0000
+++ modules/system/system.install	2006-12-30 17:22:33 +0000
@@ -336,14 +336,16 @@ function system_install() {
       ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
 
       db_query("CREATE TABLE {menu} (
-        mid int unsigned NOT NULL default '0',
-        pid int unsigned NOT NULL default '0',
         path varchar(255) NOT NULL default '',
-        title varchar(255) NOT NULL default '',
-        description varchar(255) NOT NULL default '',
-        weight tinyint NOT NULL default '0',
-        type int unsigned NOT NULL default '0',
-        PRIMARY KEY (mid)
+        access_callback varchar(255) NOT NULL default '',
+        access_arguments text,
+        page_callback varchar(255) NOT NULL default '',
+        page_arguments text,
+        map_callback varchar(255) NOT NULL default '',
+        map_arguments text,
+        fit int NOT NULL default 0,
+        number_parts int NOT NULL default 0,
+        PRIMARY KEY (path)
       ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
 
 
@@ -801,16 +803,17 @@ function system_install() {
       )");
 
       db_query("CREATE TABLE {menu} (
-        mid serial CHECK (mid >= 0),
-        pid int_unsigned NOT NULL default '0',
         path varchar(255) NOT NULL default '',
-        title varchar(255) NOT NULL default '',
-        description varchar(255) NOT NULL default '',
-        weight smallint NOT NULL default '0',
-        type int_unsigned NOT NULL default '0',
-        PRIMARY KEY (mid)
+        access_callback varchar(255) NOT NULL default '',
+        access_arguments text,
+        page_callback varchar(255) NOT NULL default '',
+        page_arguments text,
+        map_callback varchar(255) NOT NULL default '',
+        map_arguments text,
+        fit int NOT NULL default 0,
+        number_parts int NOT NULL default 0,
+        PRIMARY KEY (path)
       )");
-      db_query("ALTER SEQUENCE {menu}_mid_seq MINVALUE 2 RESTART 2");
 
       db_query("CREATE TABLE {node} (
         nid serial CHECK (nid >= 0),
@@ -1106,10 +1109,6 @@ function system_install() {
   db_query("INSERT INTO {variable} (name,value) VALUES ('filter_html_1','i:1;')");
 
   db_query("INSERT INTO {variable} (name, value) VALUES ('node_options_forum', '%s')", 'a:1:{i:0;s:6:"status";}');
-
-  db_query("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) VALUES (2, 0, '', 'Primary links', '', 0, 115)");
-  db_query("INSERT INTO {variable} VALUES ('menu_primary_menu', 'i:2;')");
-  db_query("INSERT INTO {variable} VALUES ('menu_secondary_menu', 'i:2;')");
 }
 
 // Updates for core

=== modified file 'modules/system/system.module'
--- modules/system/system.module	2006-12-27 21:59:32 +0000
+++ modules/system/system.module	2006-12-30 17:22:34 +0000
@@ -86,240 +86,222 @@ function system_elements() {
 /**
  * Implementation of hook_menu().
  */
-function system_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'system/files', 'title' => t('File download'),
-      'callback' => 'file_download',
-      'access' => TRUE,
-      'type' => MENU_CALLBACK);
-
-    $access = user_access('administer site configuration');
-
-    $items[] = array('path' => 'admin', 'title' => t('Administer'),
-      'access' => user_access('access administration pages'),
-      'callback' => 'system_main_admin_page',
-      'weight' => 9);
-    $items[] = array('path' => 'admin/compact', 'title' => t('Compact mode'),
-      'access' => user_access('access administration pages'),
-      'callback' => 'system_admin_compact_page',
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/by-task', 'title' => t('By task'),
-      'callback' => 'system_main_admin_page',
-      'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array('path' => 'admin/by-module', 'title' => t('By module'),
-      'callback' => 'system_admin_by_module',
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 2);
-
-    // menu items that are basically just menu blocks
-    $items[] = array(
-      'path' => 'admin/settings',
-      'title' => t('Site configuration'),
-      'description' => t('Adjust basic site configuration options.'),
-      'position' => 'right',
-      'weight' => -5,
-      'callback' => 'system_settings_overview',
-      'access' => $access);
-
-    $items[] = array('path' => 'admin/build',
-      'title' => t('Site building'),
-      'description' => t('Control how your site looks and feels.'),
-      'position' => 'right',
-      'weight' => -10,
-      'callback' => 'system_admin_menu_block_page',
-      'access' => $access);
-
-    $items[] = array(
-      'path' => 'admin/settings/admin',
-      'title' => t('Administration theme'),
-      'description' => t('Settings for how your administrative pages should look.'),
-      'position' => 'left',
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_admin_theme_settings'),
-      'block callback' => 'system_admin_theme_settings',
-      'access' => $access);
-
-    // Themes:
-    $items[] = array(
-      'path' => 'admin/build/themes',
-      'title' => t('Themes'),
-      'description' => t('Change which theme your site uses or allows users to set.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_themes'),
-      'access' => $access);
-
-    $items[] = array(
-      'path' => 'admin/build/themes/select',
-      'title' => t('List'),
-      'description' => t('Select the default theme.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_themes'),
-      'access' => $access,
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -1);
-
-    $items[] = array('path' => 'admin/build/themes/settings',
-      'title' => t('Configure'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_theme_settings'),
-      'access' => $access,
-      'type' => MENU_LOCAL_TASK);
-
-    // Theme configuration subtabs
-    $items[] = array('path' => 'admin/build/themes/settings/global', 'title' => t('Global settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_theme_settings'),
-      'access' => $access,
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -1);
-
-    foreach (list_themes() as $theme) {
-      if ($theme->status) {
-        $items[] = array('path' => 'admin/build/themes/settings/'. $theme->name, 'title' => $theme->name,
-        'callback' => 'drupal_get_form', 'callback arguments' => array('system_theme_settings', $theme->name),
-        'access' => $access, 'type' => MENU_LOCAL_TASK);
-      }
-    }
-
-    // Modules:
-    $items[] = array('path' => 'admin/build/modules',
-      'title' => t('Modules'),
-      'description' => t('Enable or disable add-on modules for your site.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_modules'),
-      'access' => $access);
-    $items[] = array('path' => 'admin/build/modules/list',
-      'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'access' => $access);
-    $items[] = array('path' => 'admin/build/modules/list/confirm',
-      'title' => t('List'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_modules'),
-      'type' => MENU_CALLBACK,
-      'access' => $access);
-    $items[] = array('path' => 'admin/build/modules/uninstall',
-      'title' => t('Uninstall'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_modules_uninstall'),
-      'type' => MENU_LOCAL_TASK,
-      'access' => $access);
-    $items[] = array('path' => 'admin/build/modules/uninstall/confirm',
-      'title' => t('Uninstall'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_modules_uninstall'),
-      'type' => MENU_CALLBACK,
-      'access' => $access);
-
-    // Settings:
-    $items[] = array(
-      'path' => 'admin/settings/site-information',
-      'title' => t('Site information'),
-      'description' => t('Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_site_information_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/error-reporting',
-      'title' => t('Error reporting'),
-      'description' => t('Control how Drupal deals with errors including 403/404 errors as well as PHP error reporting.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_error_reporting_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/performance',
-      'title' => t('Performance'),
-      'description' => t('Enable or disable page caching for anonymous users, and enable or disable CSS preprocessor.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_performance_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/file-system',
-      'title' => t('File system'),
-      'description' => t('Tell Drupal where to store uploaded files and how they are accessed.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_file_system_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/image-toolkit',
-      'title' => t('Image toolkit'),
-      'description' => t('Choose which image toolkit to use if you have installed optional toolkits.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_image_toolkit_settings'));
-    $items[] = array(
-      'path' => 'admin/content/rss-publishing',
-      'title' => t('RSS publishing'),
-      'description' => t('Configure the number of items per feed and whether feeds should be titles/teasers/full-text.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_rss_feeds_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/date-time',
-      'title' => t('Date and time'),
-      'description' => t("Settings for how Drupal displays date and time, as well as the system's default timezone."),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_date_time_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/site-maintenance',
-      'title' => t('Site maintenance'),
-      'description' => t('Take the site off-line for maintenance or bring it back online.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_site_maintenance_settings'));
-    $items[] = array(
-      'path' => 'admin/settings/clean-urls',
-      'title' => t('Clean URLs'),
-      'description' => t('Enable or disable clean URLs for your site.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('system_clean_url_settings'));
-
-
-    // Logs:
-    $items[] = array(
-      'path' => 'admin/logs',
-      'title' => t('Logs'),
-      'description' => t('View system logs and other status information.'),
-      'callback' => 'system_admin_menu_block_page',
-      'weight' => 5,
-      'position' => 'left');
-    $items[] = array(
-      'path' => 'admin/logs/status',
-      'title' => t('Status report'),
-      'description' => t("Get a status report about your site's operation and any detected problems."),
-      'callback' => 'system_status',
-      'weight' => 10,
-      'access' => $access);
-    $items[] = array(
-      'path' => 'admin/logs/status/run-cron',
-      'title' => t('Run cron'),
-      'callback' => 'system_run_cron',
-      'type' => MENU_CALLBACK);
-    $items[] = array(
-      'path' => 'admin/logs/status/php',
-      'title' => t('PHP'),
-      'callback' => 'system_php',
-      'type' => MENU_CALLBACK);
-    $items[] = array(
-      'path' => 'admin/logs/status/sql',
-      'title' => t('SQL'),
-      'callback' => 'system_sql',
-      'type' => MENU_CALLBACK);
-  }
-  else {
-    /**
-     * Use the administrative theme if the user is looking at a page in the admin/* path.
-     */
-    if (arg(0) == 'admin') {
-      global $custom_theme;
-      $custom_theme = variable_get('admin_theme', '0');
-      drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
+function system_menu() {
+  $items['system/files'] = array(
+    'title' => t('File download'),
+    'page callback' => 'file_download',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin'] = array(
+    'title' => t('Administer'),
+    'access arguments' => array('access administration pages'),
+    'page callback' => 'system_main_admin_page',
+    'weight' => 9,
+  );
+  $items['admin/compact'] = array(
+    'title' => t('Compact mode'),
+    'page callback' => 'system_admin_compact_page',
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/by-task'] = array(
+    'title' => t('By task'),
+    'page callback' => 'system_main_admin_page',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/by-module'] = array(
+    'title' => t('By module'),
+    'page callback' => 'system_admin_by_module',
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2,
+  );
+  // menu items that are basically just menu blocks
+  $items['admin/settings'] = array(
+    'title' => t('Site configuration'),
+    'description' => t('Adjust basic site configuration options.'),
+    'position' => 'right',
+    'weight' => -5,
+    'page callback' => 'system_settings_overview',
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['admin/build'] = array(
+    'title' => t('Site building'),
+    'description' => t('Control how your site looks and feels.'),
+    'position' => 'right',
+    'weight' => -10,
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['admin/settings/admin'] = array(
+    'title' => t('Administration theme'),
+    'description' => t('Settings for how your administrative pages should look.'),
+    'position' => 'left',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_admin_theme_settings'),
+    'block callback' => 'system_admin_theme_settings',
+  );
+  // Themes:
+  $items['admin/build/themes'] = array(
+    'title' => t('Themes'),
+    'description' => t('Change which theme your site uses or allows users to set.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_themes'),
+  );
+  $items['admin/build/themes/select'] = array(
+    'title' => t('List'),
+    'description' => t('Select the default theme.'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -1,
+  );
+  $items['admin/build/themes/settings'] = array(
+    'title' => t('Configure'),
+    'page arguments' => array('system_theme_settings'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  // Theme configuration subtabs
+  $items['admin/build/themes/settings/global'] = array(
+    'title' => t('Global settings'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -1,
+  );
+
+  foreach (list_themes() as $theme) {
+    if ($theme->status) {
+      $items['admin/build/themes/settings/'. $theme->name] = array(
+        'title' => $theme->name,
+        'page arguments' => array('system_theme_settings', $theme->name),
+        'type' => MENU_LOCAL_TASK,
+      );
     }
-
-    // Add the CSS for this module. We put this in !$may_cache so it is only
-    // added once per request.
-    drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
-    drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
   }
 
+  // Modules:
+  $items['admin/build/modules'] = array(
+    'title' => t('Modules'),
+    'description' => t('Enable or disable add-on modules for your site.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_modules'),
+  );
+  $items['admin/build/modules/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
+  $items['admin/build/modules/list/confirm'] = array(
+    'title' => t('List'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/build/modules/uninstall'] = array(
+    'title' => t('Uninstall'),
+    'page arguments' => array('system_modules_uninstall'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/build/modules/uninstall/confirm'] = array(
+    'title' => t('Uninstall'),
+    'type' => MENU_CALLBACK,
+  );
+
+  // Settings:
+  $items['admin/settings/site-information'] = array(
+    'title' => t('Site information'),
+    'description' => t('Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_site_information_settings'),
+  );
+  $items['admin/settings/error-reporting'] = array(
+    'title' => t('Error reporting'),
+    'description' => t('Control how Drupal deals with errors including 403/404 errors as well as PHP error reporting.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_error_reporting_settings'),
+  );
+  $items['admin/settings/performance'] = array(
+    'title' => t('Performance'),
+    'description' => t('Enable or disable page caching for anonymous users, and enable or disable CSS preprocessor.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_performance_settings'),
+  );
+  $items['admin/settings/file-system'] = array(
+    'title' => t('File system'),
+    'description' => t('Tell Drupal where to store uploaded files and how they are accessed.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_file_system_settings'),
+  );
+  $items['admin/settings/image-toolkit'] = array(
+    'title' => t('Image toolkit'),
+    'description' => t('Choose which image toolkit to use if you have installed optional toolkits.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_image_toolkit_settings'),
+  );
+  $items['admin/content/rss-publishing'] = array(
+    'title' => t('RSS publishing'),
+    'description' => t('Configure the number of items per feed and whether feeds should be titles/teasers/full-text.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_rss_feeds_settings'),
+  );
+  $items['admin/settings/date-time'] = array(
+    'title' => t('Date and time'),
+    'description' => t("Settings for how Drupal displays date and time, as well as the system's default timezone."),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_date_time_settings'),
+  );
+  $items['admin/settings/site-maintenance'] = array(
+    'title' => t('Site maintenance'),
+    'description' => t('Take the site off-line for maintenance or bring it back online.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_site_maintenance_settings'),
+  );
+  $items['admin/settings/clean-urls'] = array(
+    'title' => t('Clean URLs'),
+    'description' => t('Enable or disable clean URLs for your site.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('system_clean_url_settings'),
+  );
+
+  // Logs:
+  $items['admin/logs'] = array(
+    'title' => t('Logs'),
+    'description' => t('View system logs and other status information.'),
+    'page callback' => 'system_admin_menu_block_page',
+    'weight' => 5,
+    'position' => 'left',
+  );
+  $items['admin/logs/status'] = array(
+    'title' => t('Status report'),
+    'description' => t("Get a status report about your site's operation and any detected problems."),
+    'page callback' => 'system_status',
+    'weight' => 10,
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['admin/logs/status/run-cron'] = array(
+    'title' => t('Run cron'),
+    'page callback' => 'system_run_cron',
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/logs/status/php'] = array(
+    'title' => t('PHP'),
+    'page callback' => 'system_php',
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/logs/status/sql'] = array(
+    'title' => t('SQL'),
+    'page callback' => 'system_sql',
+    'type' => MENU_CALLBACK,
+  );
   return $items;
 }
 
+function system_start() {
+  // Use the administrative theme if the user is looking at a page in the admin/* path.
+  if (arg(0) == 'admin') {
+    global $custom_theme;
+    $custom_theme = variable_get('admin_theme', '0');
+    drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
+  }
+
+  // Add the CSS for this module.
+  drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
+  drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
+}
+
 /**
  * Implementation of hook_user().
  *
@@ -357,18 +339,16 @@ function system_main_admin_page($arg = N
   if (system_status(TRUE)) {
     drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/logs/status'))), 'error');
   }
+  return;
 
-
-  $menu = menu_get_item(NULL, 'admin');
-  usort($menu['children'], '_menu_sort');
-  foreach ($menu['children'] as $mid) {
-    $block = menu_get_item($mid);
-    if ($block['block callback'] && function_exists($block['block callback'])) {
+  $menu = module_invoke_all('menu', TRUE);
+  foreach ($menu as $path => $item) {
+    if (isset($item['block callback']) && function_exists($block['block callback'])) {
       $arguments = isset($block['block arguments']) ? $block['block arguments'] : array();
-      $block['content'] .= call_user_func_array($block['block callback'], $arguments);
+      $item['content'] .= call_user_func_array($block['block callback'], $arguments);
     }
-    $block['content'] .= theme('admin_block_content', system_admin_menu_block($block));
-    $blocks[] = $block;
+    $item['content'] .= theme('admin_block_content', system_admin_menu_block($block));
+    $blocks[] = $item;
   }
 
   return theme('admin_page', $blocks);
@@ -378,17 +358,6 @@ function system_main_admin_page($arg = N
  * Provide a single block on the administration overview page.
  */
 function system_admin_menu_block($block) {
-  $content = array();
-  if (is_array($block['children'])) {
-    usort($block['children'], '_menu_sort');
-    foreach ($block['children'] as $mid) {
-      $item = menu_get_item($mid);
-      if (($item['type'] & MENU_VISIBLE_IN_TREE) && _menu_item_is_accessible($mid)) {
-        $content[] = $item;
-      }
-    }
-  }
-  return $content;
 }
 
 /**

=== modified file 'modules/taxonomy/taxonomy.module'
--- modules/taxonomy/taxonomy.module	2006-12-20 10:32:16 +0000
+++ modules/taxonomy/taxonomy.module	2006-12-30 17:13:08 +0000
@@ -69,75 +69,73 @@ function taxonomy_term_path($term) {
 /**
  * Implementation of hook_menu().
  */
-function taxonomy_menu($may_cache) {
-  $items = array();
+function taxonomy_menu() {
+  $items['admin/content/taxonomy'] = array(
+    'title' => t('Categories'),
+    'description' => t('Create vocabularies and terms to categorize your content.'),
+    'page callback' => 'taxonomy_overview_vocabularies',
+    'access arguments' => array('administer taxonomy'),
+  );
 
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/content/taxonomy',
-      'title' => t('Categories'),
-      'description' => t('Create vocabularies and terms to categorize your content.'),
-      'callback' => 'taxonomy_overview_vocabularies',
-      'access' => user_access('administer taxonomy'));
-
-    $items[] = array('path' => 'admin/content/taxonomy/list',
-      'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK,
-      'weight' => -10);
-
-    $items[] = array('path' => 'admin/content/taxonomy/add/vocabulary',
-      'title' => t('Add vocabulary'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('taxonomy_form_vocabulary'),
-      'access' => user_access('administer taxonomy'),
-      'type' => MENU_LOCAL_TASK);
-
-    $items[] = array('path' => 'admin/content/taxonomy/edit/vocabulary',
-      'title' => t('Edit vocabulary'),
-      'callback' => 'taxonomy_admin_vocabulary_edit',
-      'access' => user_access('administer taxonomy'),
-      'type' => MENU_CALLBACK);
-
-    $items[] = array('path' => 'admin/content/taxonomy/edit/term',
-      'title' => t('Edit term'),
-      'callback' => 'taxonomy_admin_term_edit',
-      'access' => user_access('administer taxonomy'),
-      'type' => MENU_CALLBACK);
-
-    $items[] = array('path' => 'taxonomy/term',
-      'title' => t('Taxonomy term'),
-      'callback' => 'taxonomy_term_page',
-      'access' => user_access('access content'),
-      'type' => MENU_CALLBACK);
-
-    $items[] = array('path' => 'taxonomy/autocomplete',
-      'title' => t('Autocomplete taxonomy'),
-      'callback' => 'taxonomy_autocomplete',
-      'access' => user_access('access content'),
-      'type' => MENU_CALLBACK);
-  }
-  else {
-    if (arg(0) == 'admin' && arg(1) == 'content' && arg(2) == 'taxonomy' && is_numeric(arg(3))) {
-      $vid = arg(3);
-      $items[] = array('path' => 'admin/content/taxonomy/'. $vid,
-        'title' => t('List terms'),
-        'callback' => 'taxonomy_overview_terms',
-        'callback arguments' => array($vid),
-        'access' => user_access('administer taxonomy'),
-        'type' => MENU_CALLBACK);
-
-      $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/list',
-        'title' => t('List'),
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-        'weight' => -10);
-
-      $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/add/term',
-        'title' => t('Add term'),
-        'callback' => 'drupal_get_form',
-        'callback arguments' => array('taxonomy_form_term', $vid),
-        'access' => user_access('administer taxonomy'),
-        'type' => MENU_LOCAL_TASK);
-    }
-  }
+  $items['admin/content/taxonomy/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+
+  $items['admin/content/taxonomy/add/vocabulary'] = array(
+    'title' => t('Add vocabulary'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('taxonomy_form_vocabulary'),
+    'type' => MENU_LOCAL_TASK,
+  );
+
+  $items['admin/content/taxonomy/edit/vocabulary'] = array(
+    'title' => t('Edit vocabulary'),
+    'page callback' => 'taxonomy_admin_vocabulary_edit',
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['admin/content/taxonomy/edit/term'] = array(
+    'title' => t('Edit term'),
+    'page callback' => 'taxonomy_admin_term_edit',
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['taxonomy/term'] = array(
+    'title' => t('Taxonomy term'),
+    'page callback' => 'taxonomy_term_page',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['taxonomy/autocomplete'] = array(
+    'title' => t('Autocomplete taxonomy'),
+    'page callback' => 'taxonomy_autocomplete',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/content/taxonomy/%'] = array(
+    'title' => t('List terms'),
+    'page callback' => 'taxonomy_overview_terms',
+    'page arguments' => array(3),
+    'access arguments' => array('administer taxonomy'),
+    'map arguments' => array('taxonomy_get_vocabulary', 3),
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['admin/content/taxonomy/%/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+
+  $items['admin/content/taxonomy/%/add/term'] = array(
+    'title' => t('Add term'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('taxonomy_form_term', 3),
+    'type' => MENU_LOCAL_TASK,
+  );
 
   return $items;
 }
@@ -173,14 +171,10 @@ function taxonomy_overview_vocabularies(
  * Display a tree of all the terms in a vocabulary, with options to edit
  * each one.
  */
-function taxonomy_overview_terms($vid) {
+function taxonomy_overview_terms($vocabulary) {
   $destination = drupal_get_destination();
 
   $header = array(t('Name'), t('Operations'));
-  $vocabulary = taxonomy_get_vocabulary($vid);
-  if (!$vocabulary) {
-    return drupal_not_found();
-  }
 
   drupal_set_title(check_plain($vocabulary->name));
   $start_from      = $_GET['page'] ? $_GET['page'] : 0;
@@ -374,9 +368,7 @@ function taxonomy_vocabulary_confirm_del
   return 'admin/content/taxonomy';
 }
 
-function taxonomy_form_term($vocabulary_id, $edit = array()) {
-  $vocabulary = taxonomy_get_vocabulary($vocabulary_id);
-
+function taxonomy_form_term($vocabulary, $edit = array()) {
   $form['name'] = array(
     '#type' => 'textfield',
     '#title' => t('Term name'),
@@ -393,7 +385,7 @@ function taxonomy_form_term($vocabulary_
 
   if ($vocabulary->hierarchy) {
     $parent = array_keys(taxonomy_get_parents($edit['tid']));
-    $children = taxonomy_get_tree($vocabulary_id, $edit['tid']);
+    $children = taxonomy_get_tree($vocabulary->vid, $edit['tid']);
 
     // A term can't be the child of itself, nor of its children.
     foreach ($children as $child) {
@@ -402,15 +394,15 @@ function taxonomy_form_term($vocabulary_
     $exclude[] = $edit['tid'];
 
     if ($vocabulary->hierarchy == 1) {
-      $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
+      $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary->vid, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude);
     }
     elseif ($vocabulary->hierarchy == 2) {
-      $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
+      $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary->vid, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude);
     }
   }
 
   if ($vocabulary->relations) {
-    $form['relations'] = _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, NULL, 1, '<'. t('none') .'>', array($edit['tid']));
+    $form['relations'] = _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary->vid, NULL, 1, '<'. t('none') .'>', array($edit['tid']));
   }
 
   $form['synonyms'] = array(

=== modified file 'modules/throttle/throttle.module'
--- modules/throttle/throttle.module	2006-12-20 10:29:31 +0000
+++ modules/throttle/throttle.module	2006-12-30 17:03:00 +0000
@@ -6,21 +6,14 @@
  * Allows configuration of congestion control auto-throttle mechanism.
  */
 
-function throttle_menu($may_cache) {
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/throttle',
-      'description' => t('Control how your site cuts out content during heavy load.'),
-      'title' => t('Throttle'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('throttle_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM
-    );
-  }
-
+function throttle_menu() {
+  $items['admin/settings/throttle'] = array(
+    'description' => t('Control how your site cuts out content during heavy load.'),
+    'title' => t('Throttle'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('throttle_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+  );
   return $items;
 }
 

=== modified file 'modules/tracker/tracker.module'
--- modules/tracker/tracker.module	2006-12-29 07:59:11 +0000
+++ modules/tracker/tracker.module	2006-12-30 17:22:34 +0000
@@ -22,32 +22,34 @@ function tracker_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function tracker_menu($may_cache) {
-  global $user;
-  $items = array();
-
-  if ($may_cache) {
-    $items[] = array('path' => 'tracker', 'title' => t('Recent posts'),
-      'callback' => 'tracker_page', 'access' => user_access('access content'),
-      'weight' => 1);
-
-    if ($user->uid) {
-      $items[] = array('path' => 'tracker/all', 'title' => t('All recent posts'),
-        'type' => MENU_DEFAULT_LOCAL_TASK);
-      $items[] = array('path' => 'tracker/'. $user->uid, 'title' => t('My recent posts'),
-        'type' => MENU_LOCAL_TASK);
-    }
-  }
-  else {
-    if (arg(0) == 'user' && is_numeric(arg(1))) {
-      $items[] = array('path' => 'user/'. arg(1) .'/track', 'title' => t('Track'),
-          'callback' => 'tracker_track_user', 'access' => user_access('access content'),
-          'type' => MENU_IS_LOCAL_TASK);
-      $items[] = array('path' => 'user/'. arg(1) .'/track/posts', 'title' => t('Track posts'),
-          'type' => MENU_DEFAULT_LOCAL_TASK);
-    }
-  }
-
+function tracker_menu() {
+  $items['tracker'] = array(
+    'title' => t('Recent posts'),
+    'page callback' => 'tracker_page',
+    'access arguments' => array('access content'),
+    'weight' => 1,
+  );
+
+  $items['tracker/all'] = array(
+    'title' => t('All recent posts'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'access callback' => 'user_is_logged_in',
+  );
+  $items['tracker/%'] = array(
+    'title' => t('My recent posts'),
+    'type' => MENU_LOCAL_TASK,
+    'access callback' => 'user_is_logged_in',
+  );
+  $items['user/%/track'] = array(
+    'title' => t('Track'),
+    'page callback' => 'tracker_track_user',
+    'access arguments' => array('access content'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['user/%/track/posts'] = array(
+    'title' => t('Track posts'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
   return $items;
 }
 

=== modified file 'modules/upload/upload.module'
--- modules/upload/upload.module	2006-12-14 13:30:59 +0000
+++ modules/upload/upload.module	2006-12-14 22:27:19 +0000
@@ -59,49 +59,46 @@ function upload_link($type, $node = NULL
 /**
  * Implementation of hook_menu().
  */
-function upload_menu($may_cache) {
-  $items = array();
+function upload_menu() {
+  $items['upload/js'] = array(
+    'page callback' => 'upload_js',
+    'access arguments' => array('upload files'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/settings/uploads'] = array(
+    'title' => t('File uploads'),
+    'description' => t('Control how files may be attached to content.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('upload_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  $items['system/files'] = array(
+    'title' => t('File download'),
+    'page callback' => 'upload_download',
+    'access arguments' => array('view uploaded files'),
+    'type' => MENU_CALLBACK,
+  );
 
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'upload/js',
-      'callback' => 'upload_js',
-      'access' => user_access('upload files'),
-      'type' => MENU_CALLBACK
-    );
-    $items[] = array('path' => 'admin/settings/uploads',
-      'title' => t('File uploads'),
-      'description' => t('Control how files may be attached to content.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('upload_admin_settings'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM);
-  }
-  else {
-    // Add handlers for previewing new uploads.
-    if (isset($_SESSION['file_previews'])) {
-      foreach ($_SESSION['file_previews'] as $fid => $file) {
-        $filename = file_create_filename($file->filename, file_create_path());
-        if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) ==  FILE_DOWNLOADS_PRIVATE) {
-          // strip file_directory_path() from filename. @see file_create_url
-          if (strpos($filename, file_directory_path()) !== FALSE) {
-            $filename = trim(substr($filename, strlen(file_directory_path())), '\\/');
-          }
-          $filename = 'system/files/' . $filename;
-        }
+  return $items;
+}
 
-        $items[] = array(
-          'path' => $filename, 'title' => t('File download'),
-          'callback' => 'upload_download',
-          'access' => user_access('view uploaded files'),
-          'type' => MENU_CALLBACK
-        );
-        $_SESSION['file_previews'][$fid]->_filename = $filename;
+function upload_start() {
+  if (arg(0) == 'system' && arg(1) == 'files' && isset($_SESSION['file_previews'])) {
+    $item = menu_get_item('system/files');
+    foreach ($_SESSION['file_previews'] as $fid => $file) {
+      $filename = file_create_filename($file->filename, file_create_path());
+      if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) ==  FILE_DOWNLOADS_PRIVATE) {
+        // strip file_directory_path() from filename. @see file_create_url
+        if (strpos($filename, file_directory_path()) !== FALSE) {
+          $filename = trim(substr($filename, strlen(file_directory_path())), '\\/');
+        }
+        $filename = 'system/files/' . $filename;
       }
+      $_SESSION['file_previews'][$fid]->_filename = $filename;
+      menu_set_item($filename, $item);
     }
   }
-
-  return $items;
 }
 
 /**

=== modified file 'modules/user/user.module'
--- modules/user/user.module	2006-12-29 08:27:19 +0000
+++ modules/user/user.module	2006-12-30 17:27:42 +0000
@@ -50,6 +50,10 @@ function user_load($array = array()) {
   $query = array();
   $params = array();
 
+  if (is_numeric($array)) {
+    $array = array('uid' => $array);
+  }
+
   foreach ($array as $key => $value) {
     if ($key == 'uid' || $key == 'status') {
       $query[] = "$key = %d";
@@ -354,7 +358,7 @@ function user_access($string, $account =
   if ($account->uid == 1) {
     return TRUE;
   }
-
+  
   // To reduce the number of SQL queries, we cache the user's permissions
   // in a static variable.
   if (!isset($perm[$account->uid])) {
@@ -680,159 +684,245 @@ function theme_user_list($users, $title 
   return theme('item_list', $items, $title);
 }
 
+function user_is_anonymous() {
+  return !$GLOBALS['user']->uid;
+}
+
+function user_is_logged_in() {
+  return (bool)$GLOBALS['user']->uid;
+}
+
+function user_register_access() {
+  return !$GLOBALS['user']->uid && variable_get('user_register', 1);
+}
+
+function user_view_access($account) {
+  return $account &&
+    (
+      // Always let users view their own profile.
+      ($GLOBALS['user']->uid == $account->uid) ||
+      // Administrators can view all accounts.
+      user_access('administer users') ||
+      // The user is not blocked and logged in at least once.
+      ($account->access && $account->status && user_access('access user profiles'))
+    );
+}
+
+function user_edit_access($uid) {
+  return ($GLOBALS['user']->uid == $uid) || array('administer users');
+}
+
+function user_load_self($arg) {
+  $arg[1] = user_load($GLOBALS['user']->uid);
+  return $arg;
+}
+
 /**
  * Implementation of hook_menu().
  */
-function user_menu($may_cache) {
-  global $user;
+function user_menu() {
+  $items['user/autocomplete'] = array(
+    'title' => t('User autocomplete'),
+    'page callback' => 'user_autocomplete',
+    'access arguments' => array('access user profiles'), 
+    'type' => MENU_CALLBACK,
+  );
 
-  $items = array();
+  // Registration and login pages.
+  $items['user/login'] = array(
+    'title' => t('Log in'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_login'),
+    'access callback' => 'user_is_anonymous',
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+  );
 
-  $admin_access = user_access('administer users');
-  $access_access = user_access('administer access control');
-  $view_access = user_access('access user profiles');
-
-  if ($may_cache) {
-    $items[] = array('path' => 'user', 'title' => t('User account'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_login'),
-      'access' => !$user->uid, 'type' => MENU_CALLBACK);
-
-    $items[] = array('path' => 'user/autocomplete', 'title' => t('User autocomplete'),
-      'callback' => 'user_autocomplete', 'access' => $view_access, 'type' => MENU_CALLBACK);
-
-    // Registration and login pages.
-    $items[] = array('path' => 'user/login', 'title' => t('Log in'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_login'),
-      'access' => !$user->uid, 'type' => MENU_DEFAULT_LOCAL_TASK);
-    $items[] = array('path' => 'user/register', 'title' => t('Create new account'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_register'), 'access' => !$user->uid && variable_get('user_register', 1), 'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'user/password', 'title' => t('Request new password'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_pass'), 'access' => !$user->uid, 'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'user/reset', 'title' => t('Reset password'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_pass_reset'), 'access' => TRUE, 'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'user/help', 'title' => t('Help'),
-      'callback' => 'user_help_page', 'type' => MENU_CALLBACK);
-
-    // Admin user pages
-    $items[] = array('path' => 'admin/user',
-      'title' => t('User management'),
-      'description' => t('Manage your site\'s users, groups and access to site features.'),
-      'position' => 'left',
-      'callback' => 'system_admin_menu_block_page',
-      'access' => user_access('administer site configuration'),
-    );
-    $items[] = array('path' => 'admin/user/user', 'title' => t('Users'),
-      'description' => t('List, add, and edit users.'),
-      'callback' => 'user_admin', 'callback arguments' => array('list'), 'access' => $admin_access);
-    $items[] = array('path' => 'admin/user/user/list', 'title' => t('List'),
-      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-    $items[] = array('path' => 'admin/user/user/create', 'title' => t('Add user'),
-      'callback' => 'user_admin', 'callback arguments' => array('create'), 'access' => $admin_access,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/user/settings', 'title' => t('User settings'),
-      'description' => t('Configure default behavior of users, including registration requirements, e-mails, and user pictures.'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_settings'));
-
-    // Admin access pages
-    $items[] = array('path' => 'admin/user/access', 'title' => t('Access control'),
-      'description' => t('Determine access to features by selecting permissions for roles.'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_perm'), 'access' => $access_access);
-    $items[] = array('path' => 'admin/user/roles', 'title' => t('Roles'),
-      'description' => t('List, edit, or add user roles.'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_new_role'), 'access' => $access_access,
-      'type' => MENU_NORMAL_ITEM);
-    $items[] = array('path' => 'admin/user/roles/edit', 'title' => t('Edit role'),
-       'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_role'), 'access' => $access_access,
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/user/rules', 'title' => t('Access rules'),
-      'description' => t('List and create rules to disallow usernames, e-mail addresses, and IP addresses.'),
-      'callback' => 'user_admin_access', 'access' => $access_access);
-    $items[] = array('path' => 'admin/user/rules/list', 'title' => t('List'),
-      'access' => $access_access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-    $items[] = array('path' => 'admin/user/rules/add', 'title' => t('Add rule'),
-      'callback' => 'user_admin_access_add', 'access' => $access_access,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/user/rules/check', 'title' => t('Check rules'),
-      'callback' => 'user_admin_access_check', 'access' => $access_access,
-      'type' => MENU_LOCAL_TASK);
-    $items[] = array('path' => 'admin/user/rules/edit', 'title' => t('Edit rule'),
-      'callback' => 'user_admin_access_edit', 'access' => $access_access,
-      'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/user/rules/delete', 'title' => t('Delete rule'),
-      'callback' => 'drupal_get_form', 'callback arguments' => array('user_admin_access_delete_confirm'),
-      'access' => $access_access, 'type' => MENU_CALLBACK);
-
-    if (module_exists('search')) {
-      $items[] = array('path' => 'admin/user/search', 'title' => t('Search users'),
-        'description' => t('Search users by name.'),
-        'callback' => 'user_admin', 'callback arguments' => array('search'), 'access' => $admin_access,
-        'type' => MENU_NORMAL_ITEM);
-    }
+  $items['user/register'] = array(
+    'title' => t('Create new account'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_register'),
+    'access callback' => 'user_register_access',
+    'type' => MENU_LOCAL_TASK,
+  );
 
-    // Your personal page
-    if ($user->uid) {
-      $items[] = array('path' => 'user/'. $user->uid, 'title' => t('My account'),
-        'callback' => 'user_view', 'callback arguments' => array(arg(1)), 'access' => TRUE,
-        'type' => MENU_DYNAMIC_ITEM);
-    }
+  $items['user/password'] = array(
+    'title' => t('Request new password'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_pass'), 
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['user/reset'] = array(
+    'title' => t('Reset password'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_pass_reset'),
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+  $items['user/help'] = array(
+    'title' => t('Help'),
+    'page callback' => 'user_help_page',
+    'type' => MENU_CALLBACK,
+  );
+
+  // Admin user pages
+  $items['admin/user'] = array(
+    'title' => t('User management'),
+    'description' => t('Manage your site\'s users, groups and access to site features.'),
+    'position' => 'left',
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('administer site configuration'),
+  );
+  $items['admin/user/user'] = array(
+    'title' => t('Users'),
+    'description' => t('List, add, and edit users.'),
+    'page callback' => 'user_admin',
+    'page arguments' => array('list'),
+    'access arguments' => array('administer users'));
+  $items['admin/user/user/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/user/user/create'] = array(
+    'title' => t('Add user'),
+    'page arguments' => array('create'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/user/settings'] = array(
+    'title' => t('User settings'),
+    'description' => t('Configure default behavior of users, including registration requirements, e-mails, and user pictures.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_admin_settings'),
+  );
 
-    $items[] = array('path' => 'logout', 'title' => t('Log out'),
-      'access' => $user->uid,
-      'callback' => 'user_logout',
-      'weight' => 10);
+  // Admin access pages
+  $items['admin/user/access'] = array(
+    'title' => t('Access control'),
+    'description' => t('Determine access to features by selecting permissions for roles.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_admin_perm'),
+    'access arguments' => array('administer access control'),
+  );
+  $items['admin/user/roles'] = array(
+    'title' => t('Roles'),
+    'description' => t('List, edit, or add user roles.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_admin_new_role'),
+    'access arguments' => array('administer access control'),
+  );
+  $items['admin/user/roles/edit'] = array(
+    'title' => t('Edit role'),
+    'page arguments' => array('user_admin_role'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/user/rules'] = array(
+    'title' => t('Access rules'),
+    'description' => t('List and create rules to disallow usernames, e-mail addresses, and IP addresses.'),
+    'page callback' => 'user_admin_access',
+    'access arguments' => array('administer access control'),
+  );
+  $items['admin/user/rules/list'] = array(
+    'title' => t('List'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+  $items['admin/user/rules/add'] = array(
+    'title' => t('Add rule'),
+    'page callback' => 'user_admin_access_add',
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/user/rules/check'] = array(
+    'title' => t('Check rules'),
+    'page callback' => 'user_admin_access_check',
+    'type' => MENU_LOCAL_TASK,
+  );
+  $items['admin/user/rules/edit'] = array(
+    'title' => t('Edit rule'),
+    'page callback' => 'user_admin_access_edit',
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/user/rules/delete'] = array(
+    'title' => t('Delete rule'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_admin_access_delete_confirm'),
+    'type' => MENU_CALLBACK,
+  );
+
+  if (module_exists('search')) {
+    $items['admin/user/search'] = array(
+      'title' => t('Search users'),
+      'description' => t('Search users by name.'),
+      'page callback' => 'user_admin',
+      'page arguments' => array('search'),
+      'access arguments' => array('administer users'),
+      'type' => MENU_NORMAL_ITEM,
+    );
   }
-  else {
-    // Add the CSS for this module. We put this in !$may_cache so it is only
-    // added once per request.
-    drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
-    if ($_GET['q'] == 'user' && $user->uid) {
-      // We want to make the current user's profile accessible without knowing
-      // their uid, so just linking to /user is enough.
-      drupal_goto('user/'. $user->uid);
-    }
-
-    if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
-      $account = user_load(array('uid' => arg(1)));
-
-      if ($user !== FALSE) {
-        // Always let a user view their own account
-        $view_access |= $user->uid == arg(1);
-        // Only admins can view blocked accounts
-        $view_access &= $account->status || $admin_access;
-
-        $items[] = array('path' => 'user/'. arg(1), 'title' => t('User'),
-          'type' => MENU_CALLBACK, 'callback' => 'user_view',
-          'callback arguments' => array(arg(1)), 'access' => $view_access);
-
-        $items[] = array('path' => 'user/'. arg(1) .'/view', 'title' => t('View'),
-          'access' => $view_access, 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
-
-        $items[] = array('path' => 'user/'. arg(1) .'/edit', 'title' => t('Edit'),
-          'callback' => 'drupal_get_form', 'callback arguments' => array('user_edit'),
-          'access' => $admin_access || $user->uid == arg(1), 'type' => MENU_LOCAL_TASK);
-        $items[] = array('path' => 'user/'. arg(1) .'/delete', 'title' => t('Delete'),
-          'callback' => 'user_edit', 'access' => $admin_access,
-          'type' => MENU_CALLBACK);
-
-        if (arg(2) == 'edit') {
-          if (($categories = _user_categories($account)) && (count($categories) > 1)) {
-            foreach ($categories as $key => $category) {
-              $items[] = array(
-                'path' => 'user/'. arg(1) .'/edit/'. $category['name'],
-                'title' => $category['title'],
-                'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
-                'weight' => $category['weight'],
-                'access' => ($admin_access || $user->uid == arg(1)));
-            }
-          }
-        }
-      }
+
+  $items['logout'] = array(
+    'title' => t('Log out'),
+    'access callback' => 'user_is_logged_in',
+    'page callback' => 'user_logout',
+    'weight' => 10,
+  );
+
+  $items['user'] = array(
+    'title' => t('My account'),
+    'page callback' => 'user_view',
+    'page arguments' => array(1),
+    'access callback' => 'user_view_access',
+    'access arguments' => array(1),
+    'map callback' => 'user_load_self',
+  );
+
+  $items['user/%'] = array(
+    'title' => t('My account'),
+    'page callback' => 'user_view',
+    'page arguments' => array(1),
+    'access callback' => 'user_view_access',
+    'access arguments' => array(1),
+    'map arguments' => array('user_load', 1),
+  );
+
+  $items['user/%/view'] = array(
+    'title' => t('View'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => -10,
+  );
+
+  $items['user/%/delete'] = array(
+    'title' => t('Delete'),
+    'page callback' => 'user_edit',
+    'access callback' => 'user_access',
+    'access arguments' => array('administer users'),
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['user/%/edit'] = array(
+    'title' => t('Edit'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('user_edit'),
+    'access callback' => 'user_edit_access',
+    'access arguments' => array(1),
+    'type' => MENU_LOCAL_TASK,
+  );
+  
+  if (($categories = _user_categories($account)) && (count($categories) > 1)) {
+    foreach ($categories as $key => $category) {
+      $items['user/%/edit/'. $category['name']] = array(
+        'title' => $category['title'],
+        'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+        'weight' => $category['weight'],
+      );
     }
   }
-
   return $items;
 }
 
+function user_start() {
+  drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
+}
+
 /**
  * Accepts an user object, $account, or a DA name and returns an associative
  * array of modules and DA names. Called at external login.
@@ -1489,13 +1579,9 @@ function user_edit_submit($form_id, $for
   return 'user/'. $account->uid;
 }
 
-function user_view($uid = 0) {
+function user_view($account) {
   global $user;
 
-  $account = user_load(array('uid' => $uid));
-  if ($account === FALSE || ($account->access == 0 && !user_access('administer users'))) {
-    return drupal_not_found();
-  }
   // Retrieve and merge all profile fields:
   $fields = array();
   foreach (module_list() as $module) {

=== modified file 'modules/watchdog/watchdog.module'
--- modules/watchdog/watchdog.module	2006-12-29 17:22:20 +0000
+++ modules/watchdog/watchdog.module	2006-12-30 17:22:36 +0000
@@ -13,51 +13,40 @@
  */
 
 /**
- * Implementation of hook_help().
- */
-function watchdog_help($section) {
-  switch ($section) {
-    case 'admin/help#watchdog':
-      $output = '<p>'. t('The watchdog module monitors your system, capturing system events in a log to be reviewed by an authorized individual at a later time. This is useful for site administrators who want a quick overview of activities on their site. The logs also record the sequence of events, so it can be useful for debugging site errors.') .'</p>';
-      $output .= '<p>'. t('The watchdog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the watchdog report on a regular basis to ensure their site is working properly.') .'</p>';
-      $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="@watchdog">Watchdog page</a>.', array('@watchdog' => 'http://drupal.org/handbook/modules/watchdog/')) .'</p>';
-      return $output;
-    case 'admin/logs':
-      return '<p>'. t('The watchdog module monitors your web site, capturing system events in a log to be reviewed by an authorized individual at a later time. The watchdog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the watchdog report on a regular basis as it is often the only way to tell what is going on.') .'</p>';
-  }
-}
-
-/**
  * Implementation of hook_menu().
  */
-function watchdog_menu($may_cache) {
-  $items = array();
+function watchdog_menu() {
+  $items['admin/logs/watchdog'] = array(
+    'title' => t('Recent log entries'),
+    'description' => t('View events that have recently been logged.'),
+    'page callback' => 'watchdog_overview',
+    'weight' => -1,
+  );
+  $items['admin/logs/page-not-found'] = array(
+    'title' => t("Top 'page not found' errors"),
+    'description' => t("View 'page not found' errors (404s)."),
+    'page callback' => 'watchdog_top',
+    'page arguments' => array('page not found'),
+  );
+  $items['admin/logs/access-denied'] = array(
+      'title' => t("Top 'access denied' errors"),
+    'description' => t("View 'access denied' errors (403s)."),
+    'page callback' => 'watchdog_top',
+    'page arguments' => array('access denied'),
+  );
+  $items['admin/logs/event'] = array(
+    'title' => t('Details'),
+    'page callback' => 'watchdog_event',
+    'type' => MENU_CALLBACK,
+  );
+  return $items;
+}
 
-  if ($may_cache) {
-    $items[] = array('path' => 'admin/logs/watchdog', 'title' => t('Recent log entries'),
-      'description' => t('View events that have recently been logged.'),
-      'callback' => 'watchdog_overview',
-      'weight' => -1);
-    $items[] = array('path' => 'admin/logs/page-not-found', 'title' => t("Top 'page not found' errors"),
-      'description' => t("View 'page not found' errors (404s)."),
-      'callback' => 'watchdog_top',
-      'callback arguments' => array('page not found'));
-    $items[] = array('path' => 'admin/logs/access-denied', 'title' => t("Top 'access denied' errors"),
-      'description' => t("View 'access denied' errors (403s)."),
-      'callback' => 'watchdog_top',
-      'callback arguments' => array('access denied'));
-    $items[] = array('path' => 'admin/logs/event', 'title' => t('Details'),
-      'callback' => 'watchdog_event',
-      'type' => MENU_CALLBACK);
+function watchdog_start() {
+  if (arg(0) == 'admin' && arg(1) == 'logs') {
+    // Add the CSS for this module
+    drupal_add_css(drupal_get_path('module', 'watchdog') .'/watchdog.css', 'module', 'all', FALSE);
   }
-  else {
-    if (arg(0) == 'admin' && arg(1) == 'logs') {
-      // Add the CSS for this module
-      drupal_add_css(drupal_get_path('module', 'watchdog') .'/watchdog.css', 'module', 'all', FALSE);
-    }
-  }
-
-  return $items;
 }
 
 /**

=== modified file 'profiles/default/default.profile'
--- profiles/default/default.profile	2006-10-29 13:17:38 +0000
+++ profiles/default/default.profile	2006-12-14 22:27:19 +0000
@@ -8,7 +8,7 @@
  *  An array of modules to be enabled.
  */
 function default_profile_modules() {
-  return array('block', 'color', 'comment', 'filter', 'help', 'menu', 'node', 'system', 'taxonomy', 'user', 'watchdog');
+  return array('block', 'color', 'comment', 'filter', 'help', 'node', 'system', 'taxonomy', 'user', 'watchdog');
 }
 
 /**

