? modules/node/node.content_forms.inc
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.190
diff -u -p -r1.190 menu.inc
--- includes/menu.inc	4 Aug 2007 13:58:06 -0000	1.190
+++ includes/menu.inc	6 Aug 2007 01:20:19 -0000
@@ -163,7 +163,7 @@ define('MENU_MAX_PARTS', 6);
 /**
  * The maximum depth of a menu links tree - matches the number of p columns.
  */
-define('MENU_MAX_DEPTH', 6);
+define('MENU_MAX_DEPTH', 9);
 
 
 /**
@@ -570,17 +570,21 @@ function menu_tree($menu_name = 'navigat
  *
  * @param $tree
  *   A data structure representing the tree as returned from menu_tree_data.
+ * @param $show_disabled
+ *   Show disabled links (such as suggested menu items).
  * @return
  *   The rendered HTML of that data structure.
  */
-function menu_tree_output($tree) {
+function menu_tree_output($tree, $show_disabled = FALSE) {
   $output = '';
 
+  // We may want to show links that are visible or disabled (hidden is 0 or 1),
+  // but not menu callbacks (hidden is -1).
   foreach ($tree as $data) {
-    if (!$data['link']['hidden']) {
+    if (!$data['link']['hidden'] || ($show_disabled && $data['link']['hidden'] == 1)) {
       $link = theme('menu_item_link', $data['link']);
       if ($data['below']) {
-        $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail']);
+        $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below'], $show_disabled), $data['link']['in_active_trail']);
       }
       else {
         $output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail']);
@@ -602,18 +606,16 @@ function menu_tree_output($tree) {
  *   A fully loaded menu link, or NULL.  If a link is supplied, only the
  *   path to root will be included in the returned tree- as if this link
  *   represented the current page in a visible menu.
- * @param $show_hidden
- *   Show disabled links (such as suggested menu items).
  * @return
  *   An tree of menu links in an array, in the order they should be rendered.
  */
-function menu_tree_all_data($menu_name = 'navigation', $item = NULL, $show_hidden = FALSE) {
+function menu_tree_all_data($menu_name = 'navigation', $item = NULL) {
   static $tree = array();
 
   // Use $mlid as a flag for whether the data being loaded is for the whole tree.
   $mlid = isset($item['mlid']) ? $item['mlid'] : 0;
   // Generate the cache ID.
-  $cid = 'links:'. $menu_name .':all:'. $mlid .':'. (int)$show_hidden;
+  $cid = 'links:'. $menu_name .':all:'. $mlid;
 
   if (!isset($tree[$cid])) {
     // If the static variable doesn't have the data, check {cache_menu}.
@@ -626,7 +628,10 @@ function menu_tree_all_data($menu_name =
       if ($mlid) {
         // The tree is for a single item, so we need to match the values in its
         // p columns and 0 (the top level) with the plid values of other links.
-        $args = array(0, $item['p1'], $item['p2'], $item['p3'], $item['p4'], $item['p5']);
+        $args = array(0);
+        for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
+          $args[] = $item["p$i"];
+        }
         $args = array_unique($args);
         $placeholders = implode(', ', array_fill(0, count($args), '%d'));
         $where = ' AND ml.plid IN ('. $placeholders .')';
@@ -642,22 +647,19 @@ function menu_tree_all_data($menu_name =
       array_unshift($args, $menu_name);
       // Select the links from the table, and recursively build the tree.  We
       // LEFT JOIN since there is no match in {menu_router} for an external
-      // link. We need to select links that are visible or hidden
-      // (ml.hidden >= 0), but not callbacks (ml.hidden < 0), so that we can
-      // later exclude all the children of a hidden item.
-      // No need to order by p6 - there is a sort by weight later.
+      // link. No need to order by p9 - there is a sort by weight later.
       $data['tree'] = menu_tree_data(db_query("
         SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
         FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
-        WHERE ml.menu_name = '%s'". $where ." AND ml.hidden >= 0
-        ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC", $args), $parents);
+        WHERE ml.menu_name = '%s'". $where ."
+        ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC", $args), $parents);
       $data['node_links'] = array();
       menu_tree_collect_node_links($data['tree'], $data['node_links']);
       // Cache the data.
       cache_set($cid, $data, 'cache_menu');
     }
     // Check access for the current user to each item in the tree.
-    menu_tree_check_access($data['tree'], $data['node_links'], $show_hidden);
+    menu_tree_check_access($data['tree'], $data['node_links']);
     $tree[$cid] = $data['tree'];
   }
 
@@ -697,12 +699,12 @@ function menu_tree_page_data($menu_name 
         // Build and run the query, and build the tree.
         if ($item['access']) {
           // Check whether a menu link exists that corresponds to the current path.
-          $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['href']));
+          $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['href']));
 
           if (empty($parents)) {
             // If no link exists, we may be on a local task that's not in the links.
             // TODO: Handle the case like a local task on a specific node in the menu.
-            $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root']));
+            $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root']));
           }
           // We always want all the top-level links with plid == 0.
           $parents[] = '0';
@@ -715,7 +717,7 @@ function menu_tree_page_data($menu_name 
             // Collect all the links set to be expanded, and then add all of
             // their children to the list as well.
             do {
-              $result = db_query("SELECT mlid FROM {menu_links} WHERE expanded != 0 AND has_children != 0 AND menu_name = '%s' AND plid IN (". $placeholders .') AND mlid NOT IN ('. $placeholders .')', array_merge(array($menu_name), $args, $args));
+              $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded != 0 AND has_children != 0 AND plid IN (". $placeholders .') AND mlid NOT IN ('. $placeholders .')', array_merge(array($menu_name), $args, $args));
               while ($item = db_fetch_array($result)) {
                 $args[] = $item['mlid'];
               }
@@ -732,15 +734,12 @@ function menu_tree_page_data($menu_name 
         }
         // Select the links from the table, and recursively build the tree. We
         // LEFT JOIN since there is no match in {menu_router} for an external
-        // link. We need to select links that are visible or hidden
-        // (ml.hidden >= 0), but not callbacks (ml.hidden < 0), so that we can
-        // later exclude all the children of a hidden item.
-        // No need to order by p6 - there is a sort by weight later.
+        // link. No need to order by p9 - there is a sort by weight later.
         $data['tree'] = menu_tree_data(db_query("
           SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
           FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
-          WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .") AND ml.hidden >= 0
-          ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC", $args), $parents);
+          WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .")
+          ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC", $args), $parents);
         $data['node_links'] = array();
         menu_tree_collect_node_links($data['tree'], $data['node_links']);
         // Cache the data.
@@ -778,7 +777,7 @@ function menu_tree_collect_node_links(&$
 /**
  * Check access and perform other dynamic operations for each link in the tree.
  */
-function menu_tree_check_access(&$tree, $node_links = array(), $show_hidden = FALSE) {
+function menu_tree_check_access(&$tree, $node_links = array()) {
 
   if ($node_links) {
     // Use db_rewrite_sql to evaluate view access without loading each full node.
@@ -789,26 +788,21 @@ function menu_tree_check_access(&$tree, 
       $node_links[$node['nid']]['access'] = TRUE;
     }
   }
-  _menu_tree_check_access($tree, $show_hidden);
+  _menu_tree_check_access($tree);
   return;
 }
 
 /**
  * Recursive helper function for menu_tree_check_access()
  */
-function _menu_tree_check_access(&$tree, $show_hidden) {
+function _menu_tree_check_access(&$tree) {
   $new_tree = array();
   foreach ($tree as $key => $v) {
     $item = &$tree[$key]['link'];
-    if (!$item['hidden'] || $show_hidden) {
-      _menu_link_translate($item);
-    }
-    else {
-      $item['access'] = FALSE;
-    }
+    _menu_link_translate($item);
     if ($item['access']) {
       if ($tree[$key]['below']) {
-        _menu_tree_check_access($tree[$key]['below'], $show_hidden);
+        _menu_tree_check_access($tree[$key]['below']);
       }
       // The weights are made a uniform 5 digits by adding 50000 as an offset.
       // After _menu_link_translate(), $item['title'] has the localized link title.
@@ -877,7 +871,7 @@ function _menu_tree_data($result, $paren
         // Only the first time.
         $tree[$index] = array(
           'link' => $previous_element,
-          'below' => '',
+          'below' => FALSE,
         );
       }
       // This will be the link to be output in the next iteration.
@@ -893,7 +887,7 @@ function _menu_tree_data($result, $paren
     // We have one more link dangling.
     $tree[$previous_element['mlid']] = array(
       'link' => $previous_element,
-      'below' => '',
+      'below' => FALSE,
     );
   }
   return array($remnant, $tree);
@@ -1031,10 +1025,12 @@ function menu_secondary_links() {
  *   a parent tab, if the current page is a default local task.
  */
 function menu_local_tasks($level = 0, $return_root = FALSE) {
-  static $tabs = array();
+  static $tabs;
   static $root_path;
-
-  if (empty($tabs)) {
+  
+  if (!isset($tabs)) {
+    $tabs = array();
+    
     $router_item = menu_get_item();
     if (!$router_item || !$router_item['access']) {
       return '';
@@ -1549,7 +1545,9 @@ function menu_link_save(&$item) {
 
   if (!$item['plid']) {
     $item['p1'] = $item['mlid'];
-    $item['p2'] = $item['p3'] = $item['p4'] = $item['p5'] = $item['p6'] = 0;
+    for ($i = 2; $i <= MENU_MAX_DEPTH; $i++) {
+      $item["p$i"] = 0;
+    }
     $item['depth'] = 1;
   }
   else {
@@ -1593,12 +1591,12 @@ function menu_link_save(&$item) {
   db_query("UPDATE {menu_links} SET menu_name = '%s', plid = %d, link_path = '%s',
     router_path = '%s', hidden = %d, external = %d, has_children = %d,
     expanded = %d, weight = %d,  depth = %d,
-    p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, p6 = %d,
+    p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, p6 = %d, p7 = %d, p8 = %d, p9 = %d,
     module = '%s', link_title = '%s', options = '%s', customized = %d WHERE mlid = %d",
     $item['menu_name'], $item['plid'], $item['link_path'],
     $item['router_path'], $item['hidden'], $item['_external'], $item['has_children'],
     $item['expanded'], $item['weight'],  $item['depth'],
-    $item['p1'], $item['p2'], $item['p3'], $item['p4'], $item['p5'], $item['p6'],
+    $item['p1'], $item['p2'], $item['p3'], $item['p4'], $item['p5'], $item['p6'], $item['p7'], $item['p8'], $item['p9'],
     $item['module'],  $item['link_title'], serialize($item['options']), $item['customized'], $item['mlid']);
   // Check the has_children status of the parent.
   if ($item['plid']) {
@@ -1688,7 +1686,8 @@ function _menu_link_move_children($item,
     $args[] = $shift;
     $set[] = 'depth = depth + %d';
   }
-
+  $where[] = "menu_name = '%s'";
+  $args[] = $existing_item['menu_name'];
   $p = 'p1';
   for ($i = 1; $i <= MENU_MAX_DEPTH && $existing_item[$p]; $p = 'p'. ++$i) {
     $where[] = "$p = %d";
@@ -1704,7 +1703,7 @@ function _menu_link_move_children($item,
 }
 
 /**
- * Helper function that sets the p1..p6 values for a menu link being saved.
+ * Helper function that sets the p1..p9 values for a menu link being saved.
  */
 function _menu_link_parents_set(&$item, $parent) {
   $i = 1;
@@ -1713,7 +1712,7 @@ function _menu_link_parents_set(&$item, 
     $item[$p] = $parent[$p];
   }
   $p = 'p'. $i++;
-  // The parent (p1 - p6) corresponding to the depth always equals the mlid.
+  // The parent (p1 - p9) corresponding to the depth always equals the mlid.
   $item[$p] = $item['mlid'];
   while ($i <= MENU_MAX_DEPTH) {
     $p = 'p'. $i++;
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.430
diff -u -p -r1.430 book.module
--- modules/book/book.module	4 Aug 2007 21:24:32 -0000	1.430
+++ modules/book/book.module	6 Aug 2007 01:20:20 -0000
@@ -1449,8 +1449,9 @@ function book_menu_subtree_data($item) {
       $data = $cache->data;
     }
     else {
+      $match = array("menu_name  = '%s'");
+      $args = array($item['menu_name']);
       $i = 1;
-      $match = array();
       while ($i <= MENU_MAX_DEPTH && $item["p$i"]) {
         $match[] = "p$i = %d";
         $args[] = $item["p$i"];
@@ -1460,8 +1461,8 @@ function book_menu_subtree_data($item) {
         SELECT b.*, m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
         FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
         INNER JOIN {book} b ON ml.mlid = b.mlid
-        WHERE ml.hidden >= 0 AND ". implode(' AND ', $match) ."
-        ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC";
+        WHERE ". implode(' AND ', $match) ."
+        ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC";
 
       $data['tree'] = menu_tree_data(db_query($sql, $args), array(), $item['depth']);
       $data['node_links'] = array();
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.132
diff -u -p -r1.132 menu.module
--- modules/menu/menu.module	29 Jul 2007 17:28:23 -0000	1.132
+++ modules/menu/menu.module	6 Aug 2007 01:20:20 -0000
@@ -134,7 +134,7 @@ function menu_enable() {
 
   while ($menu = db_fetch_array($result)) {
     $link['mlid'] = 0;
-    $link['link_title'] = $menu['title'];
+    $link['link_title'] = $menu['title'] .' '. t('(overview)');
     $link['link_path'] = 'admin/build/menu-customize/'. $menu['menu_name'];
     menu_link_save($link);
   }
@@ -379,7 +379,7 @@ function menu_edit_item_submit($form, &$
 function menu_parent_options($menus, $item) {
 
   foreach ($menus as $menu_name => $title) {
-    $tree = menu_tree_all_data($menu_name, NULL, TRUE);
+    $tree = menu_tree_all_data($menu_name, NULL);
     $options[$menu_name .':0'] = '<'. $title .'>';
     _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid']);
   }
@@ -391,7 +391,7 @@ function menu_parent_options($menus, $it
  */
 function _menu_parents_recurse($tree, $menu_name, $indent, &$options, $exclude) {
   foreach ($tree as $data) {
-    if ($data['link']['mlid'] != $exclude) {
+    if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
       $title = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
       if ($data['link']['hidden']) {
         $title .= ' ('. t('disabled') .')';
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.131
diff -u -p -r1.131 system.install
--- modules/system/system.install	11 Jul 2007 15:15:40 -0000	1.131
+++ modules/system/system.install	6 Aug 2007 01:20:20 -0000
@@ -3333,6 +3333,9 @@ function system_update_6020() {
       'plid'         => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'link_path'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
       'router_path'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'link_title'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'options'      => array('type' => 'text', 'not null' => FALSE),
+      'module'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
       'hidden'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
       'external'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
       'has_children' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
@@ -3346,16 +3349,15 @@ function system_update_6020() {
       'p4'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'p5'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'p6'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-      'module'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
-      'link_title'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
-      'options'      => array('type' => 'text', 'not null' => FALSE)
+      'p7'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'p8'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'p9'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
     ),
     'indexes' => array(
-      'expanded_children' => array('expanded', 'has_children'),
-      'menu_name_path' => array('menu_name', 'link_path'),
-      'plid'=> array('plid'),
-      'parents' => array('p1', 'p2', 'p3', 'p4', 'p5'),
-      'router_path' => array('router_path'),
+      'link_path' => array(array('link_path', 128), 'menu_name'),
+      'menu_name_plid'=> array('menu_name', 'plid'),
+      'parents' => array('menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8'),
+      'router_path' => array(array('router_path', 128)),
     ),
     'primary key' => array('mlid'),
   );
Index: modules/system/system.schema
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.schema,v
retrieving revision 1.8
diff -u -p -r1.8 system.schema
--- modules/system/system.schema	15 Jul 2007 10:09:21 -0000	1.8
+++ modules/system/system.schema	6 Aug 2007 01:20:20 -0000
@@ -104,6 +104,9 @@ function system_schema() {
       'plid'         => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'link_path'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
       'router_path'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'link_title'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
+      'options'      => array('type' => 'text', 'not null' => FALSE),
+      'module'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
       'hidden'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
       'external'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
       'has_children' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
@@ -117,16 +120,15 @@ function system_schema() {
       'p4'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'p5'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'p6'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
-      'module'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
-      'link_title'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
-      'options'      => array('type' => 'text', 'not null' => FALSE)
+      'p7'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'p8'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'p9'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
     ),
     'indexes' => array(
-      'expanded_children' => array('expanded', 'has_children'),
-      'menu_name_path' => array('menu_name', 'link_path'),
-      'plid'=> array('plid'),
-      'parents' => array('p1', 'p2', 'p3', 'p4', 'p5'),
-      'router_path' => array('router_path'),
+      'link_path' => array(array('link_path', 128), 'menu_name'),
+      'menu_name_plid'=> array('menu_name', 'plid'),
+      'parents' => array('menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8'),
+      'router_path' => array(array('router_path', 128)),
     ),
     'primary key' => array('mlid'),
   );
