All pastes #516784 Raw Edit

Untitled

public text v1 · immutable
#516784 ·published 2007-05-28 21:04 UTC
rendered paste body
=== modified file 'includes/menu.inc'
--- includes/menu.inc	2007-05-28 06:24:41 +0000
+++ includes/menu.inc	2007-05-28 21:00:27 +0000
@@ -303,7 +303,8 @@ function menu_get_item($path = NULL) {
 function menu_execute_active_handler($path = NULL) {
   if (_menu_site_is_offline()) {
     return MENU_SITE_OFFLINE;
-  }  if ($router_item = menu_get_item($path)) {
+  }
+  if ($router_item = menu_get_item($path)) {
     if ($router_item['access']) {
       if ($router_item['file']) {
         require_once($router_item['file']);
@@ -884,7 +885,7 @@ function menu_get_names($reset = FALSE)
 }

 function menu_primary_links() {
-  $tree = menu_tree_page_data('primary_links');
+  $tree = menu_tree_page_data('primary-links');
   $links = array();
   foreach ($tree as $item) {
     $l = $item['link']['options'];
@@ -896,7 +897,7 @@ function menu_primary_links() {
 }

 function menu_secondary_links() {
-  $tree = menu_tree_page_data('secondary_links');
+  $tree = menu_tree_page_data('secondary-links');
   $links = array();
   foreach ($tree as $item) {
     $l = $item['link']['options'];
@@ -1132,7 +1133,6 @@ function menu_link_load($mlid) {
 }

 function menu_cache_clear($menu_name = 'navigation') {
-
   cache_clear_all('links:'. $menu_name .':', 'cache_menu', TRUE);
 }

@@ -1187,26 +1187,31 @@ function menu_router_build($reset = FALS
   return $menu;
 }

+function menu_link_build($item) {
+  if ($item['type'] == MENU_CALLBACK) {
+    $item['hidden'] = -1;
+  }
+  elseif  ($item['type'] == MENU_SUGGESTED_ITEM) {
+    $item['hidden'] = 1;
+  }
+  // Note, we set this as 'system', so that we can be sure to distinguish all
+  // the menu links generated automatically from entries in {menu_router}.
+  $item['module'] = 'system';
+  $item += array(
+    'menu_name' => 'navigation',
+    'link_title' => $item['title'],
+    'link_path' => $item['path'],
+    'hidden' => 0,
+    'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])),
+  );
+  return $item;
+}
+
 function _menu_navigation_links_rebuild($menu) {
   // Add normal and suggested items as links.
   $menu_links = array();
   foreach ($menu as $path => $item) {
-    if ($item['type'] == MENU_CALLBACK) {
-      $item['hidden'] = -1;
-    }
-    elseif  ($item['type'] == MENU_SUGGESTED_ITEM) {
-      $item['hidden'] = 1;
-    }
-    // Note, we set this as 'system', so that we can be sure to distinguish all
-    // the menu links generated automatically from entries in {menu_router}.
-    $item['module'] = 'system';
-    $item += array(
-      'menu_name' => 'navigation',
-      'link_title' => $item['title'],
-      'link_path' => $path,
-      'hidden' => 0,
-      'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])),
-    );
+    $item = menu_link_build($item);
     // We add nonexisting items.
     if ($item['_visible'] && !db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $item['menu_name'], $item['link_path']))) {
       $menu_links[$path] = $item;
@@ -1247,7 +1252,6 @@ function menu_link_delete($mlid, $path =
 }

 function _menu_delete_item($item) {
-
   // System-created items get automatically deleted, but only on menu rebuild.
   if ($item && $item['module'] != 'system') {

@@ -1261,12 +1265,10 @@ function _menu_delete_item($item) {
       }
     }
     db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']);
-
-    // Update the has_children status of the parent
-    $children = (bool)db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE plid = %d AND hidden = 0", $item['plid']));
-    db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $children, $item['plid']);
-
     menu_cache_clear($item['menu_name']);
+    $t_args = array('%title' => $item['link_title']);
+    drupal_set_message(t('The menu item %title has been deleted.', $t_args));
+    watchdog('menu', 'Deleted menu item %title.', $t_args, WATCHDOG_NOTICE);
   }
 }

@@ -1427,7 +1429,7 @@ function menu_link_save(&$item) {
     $names[] = $n['menu_name'];
   }
   variable_set('menu_expanded', $names);
-  return TRUE;
+  return $item['mlid'];
 }

 /**