diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-05-16 13:45:17 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-05-16 13:45:17 +0000 |
commit | a243145d3fef5996394518a2a3a9f8254ed2202a (patch) | |
tree | bc4306713d48882a357e36d3b82661870c179dd8 /modules | |
parent | b4ef53eccc40dd8605a625adbacb603d93fb3acc (diff) | |
download | brdo-a243145d3fef5996394518a2a3a9f8254ed2202a.tar.gz brdo-a243145d3fef5996394518a2a3a9f8254ed2202a.tar.bz2 |
- Patch #137767 by chx and pwolanin: multiple menu support.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/menu/menu.module | 35 | ||||
-rw-r--r-- | modules/node/content_types.inc | 2 | ||||
-rw-r--r-- | modules/node/node.module | 2 | ||||
-rw-r--r-- | modules/path/path.module | 3 | ||||
-rw-r--r-- | modules/system/system.install | 115 | ||||
-rw-r--r-- | modules/system/system.module | 25 | ||||
-rw-r--r-- | modules/tracker/tracker.module | 1 | ||||
-rw-r--r-- | modules/user/user.module | 12 |
8 files changed, 101 insertions, 94 deletions
diff --git a/modules/menu/menu.module b/modules/menu/menu.module index 2dfda5984..8ba005110 100644 --- a/modules/menu/menu.module +++ b/modules/menu/menu.module @@ -125,35 +125,6 @@ function menu_menu() { */ } -/** - * Implementation of hook_menu_alter. - */ -function menu_menu_alter(&$menu, $phase) { - switch ($phase) { - case MENU_ALTER_MODULE_DEFINED: - foreach ($menu as $path => $item) { - if (isset($item['_custom_item']) && $item['_custom_item'] && !$item['_external']) { - list($ancestors, $placeholders) = menu_get_ancestors(explode('/', $path, 6)); - // Remove the item itself, custom items need to inherit from an existing item. - array_shift($ancestors); - array_shift($placeholders); - $inherit_item = db_fetch_object(db_query_range('SELECT * FROM {menu} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1)); - drupal_set_message(var_export($inherit_item, TRUE)); - $menu[$path]['access callback'] = $inherit_item->access_callback; - $menu[$path]['access arguments'] = unserialize($inherit_item->access_arguments); - $menu[$path]['page callback'] = $inherit_item->page_callback; - $menu[$path]['page arguments'] = unserialize($inherit_item->page_arguments); - } - } - break; - case MENU_ALTER_PREPROCESSED: - $result = db_query('SELECT * FROM {menu_custom} me WHERE admin = 0'); - while ($item = db_fetch_array($result)) { - $menu[$item['path']] = $item + $menu[$item['path']]; - } - break; - } -} /** * Menu callback which displays every menu element accessible to the current @@ -161,6 +132,8 @@ function menu_menu_alter(&$menu, $phase) { */ function menu_overview() { $header = array(t('Menu item'), t('Expanded'), array('data' => t('Operations'), 'colspan' => '3')); + + $result = db_query('SELECT m.*, me.disabled FROM {menu} m LEFT JOIN {menu_custom} me ON m.path = me.path WHERE visible = 1 OR (disabled = 1 AND admin = 0) ORDER BY mleft'); $map = arg(); $rows = array(); @@ -677,6 +650,10 @@ function _menu_form_alter(&$form, $form_id) { } } +function menu_get_root_menus() { + return array(); +} + /** * Menu callback; presents menu configuration options. */ diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index ae6ba1e06..91ec2ac86 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -320,7 +320,7 @@ function node_type_form_submit($form_values, $form, &$form_state) { } node_types_rebuild(); - // menu_rebuild clears the cache, too + cache_clear_all(); menu_rebuild(); $t_args = array('%name' => $type->name); diff --git a/modules/node/node.module b/modules/node/node.module index 8113c6cdd..27f0bce96 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1248,6 +1248,7 @@ function node_menu() { 'title' => 'Edit', 'page callback' => 'node_page_edit', 'page arguments' => array(1), + 'access callback' => 'node_access', 'access arguments' => array('update', 1), 'weight' => 1, 'type' => MENU_LOCAL_TASK); @@ -1255,6 +1256,7 @@ function node_menu() { 'title' => 'Delete', 'page callback' => 'drupal_get_form', 'page arguments' => array('node_delete_confirm', 1), + 'access callback' => 'node_access', 'access arguments' => array('delete', 1), 'weight' => 1, 'type' => MENU_CALLBACK); diff --git a/modules/path/path.module b/modules/path/path.module index d6beffcf1..59920c7d5 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -128,13 +128,11 @@ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '' if ($path && !$alias) { // Delete based on path db_query("DELETE FROM {url_alias} WHERE src = '%s' AND language = '%s'", $path, $language); - db_query("UPDATE {menu} SET link_path = path WHERE path = '%s'", $path); drupal_clear_path_cache(); } else if (!$path && $alias) { // Delete based on alias db_query("DELETE FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $alias, $language); - db_query("UPDATE {menu} SET link_path = path WHERE link_path = '%s'", $alias); drupal_clear_path_cache(); } else if ($path && $alias) { @@ -170,7 +168,6 @@ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '' } if ($alias_count == 0 || $path_count == 0) { drupal_clear_path_cache(); - db_query("UPDATE {menu} SET link_path = '%s' WHERE path = '%s'", $alias, $path); } } } diff --git a/modules/system/system.install b/modules/system/system.install index a1275b25c..e25302004 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -345,9 +345,7 @@ function system_install() { PRIMARY KEY (uid,nid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - db_query("CREATE TABLE {menu} ( - mid int NOT NULL default 0, - pid int NOT NULL default 0, + db_query("CREATE TABLE {menu_router} ( path varchar(255) NOT NULL default '', load_functions varchar(255) NOT NULL default '', to_arg_functions varchar(255) NOT NULL default '', @@ -357,32 +355,46 @@ function system_install() { page_arguments text, fit int NOT NULL default 0, number_parts int NOT NULL default 0, - mleft int NOT NULL default 0, - mright int NOT NULL default 0, - visible int NOT NULL default 0, - parents varchar(255) NOT NULL default '', - depth int NOT NULL default 0, - has_children int NOT NULL default 0, - tab int NOT NULL default 0, + tab_parent varchar(255) NOT NULL default '', + tab_root varchar(255) NOT NULL default '', title varchar(255) NOT NULL default '', title_callback varchar(255) NOT NULL default '', title_arguments varchar(255) NOT NULL default '', - parent varchar(255) NOT NULL default '', type int NOT NULL default 0, block_callback varchar(255) NOT NULL default '', description varchar(255) NOT NULL default '', position varchar(255) NOT NULL default '', - link_path varchar(255) NOT NULL default '', - attributes varchar(255) NOT NULL default '', - query varchar(255) NOT NULL default '', - fragment varchar(255) NOT NULL default '', - absolute INT NOT NULL default 0, - html INT NOT NULL default 0, + weight int NOT NULL default 0, PRIMARY KEY (path), KEY fit (fit), - KEY visible (visible), - KEY pid (pid), - KEY parent (parent) + KEY tab_parent (tab_parent) + ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); + + db_query("CREATE TABLE {menu_links} ( + menu_name varchar(64) NOT NULL default '', + mlid int NOT NULL default '0', + plid int NOT NULL default '0', + href varchar(255) NOT NULL default '', + router_path varchar(255) NOT NULL default '', + hidden smallint NOT NULL default '0', + external smallint NOT NULL default '0', + has_children int NOT NULL default '0', + expanded smallint NOT NULL default '0', + weight int NOT NULL default '0', + depth int NOT NULL default '0', + p1 int NOT NULL default '0', + p2 int NOT NULL default '0', + p3 int NOT NULL default '0', + p4 int NOT NULL default '0', + p5 int NOT NULL default '0', + p6 int NOT NULL default '0', + module varchar(255) NOT NULL default 'system', + link_title varchar(255) NOT NULL default '', + options text, + PRIMARY KEY (mlid), + KEY parents (plid, p1, p2, p3, p4, p5), + KEY menu_name_path (menu_name, href), + KEY menu_expanded_children (expanded, has_children) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); db_query("CREATE TABLE {node} ( @@ -840,9 +852,7 @@ function system_install() { PRIMARY KEY (uid,nid) )"); - db_query("CREATE TABLE {menu} ( - mid int NOT NULL default 0, - pid int NOT NULL default 0, + db_query("CREATE TABLE {menu_router} ( path varchar(255) NOT NULL default '', load_functions varchar(255) NOT NULL default '', to_arg_functions varchar(255) NOT NULL default '', @@ -852,34 +862,47 @@ function system_install() { page_arguments text, fit int NOT NULL default 0, number_parts int NOT NULL default 0, - mleft int NOT NULL default 0, - mright int NOT NULL default 0, - visible int NOT NULL default 0, - parents varchar(255) NOT NULL default '', - depth int NOT NULL default 0, - has_children int NOT NULL default 0, - tab int NOT NULL default 0, + tab_parent varchar(255) NOT NULL default '', + tab_root varchar(255) NOT NULL default '', title varchar(255) NOT NULL default '', title_callback varchar(255) NOT NULL default '', title_arguments varchar(255) NOT NULL default '', - parent varchar(255) NOT NULL default '', type int NOT NULL default 0, block_callback varchar(255) NOT NULL default '', description varchar(255) NOT NULL default '', position varchar(255) NOT NULL default '', - link_path varchar(255) NOT NULL default '', - attributes varchar(255) NOT NULL default '', - query varchar(255) NOT NULL default '', - fragment varchar(255) NOT NULL default '', - absolute INT NOT NULL default 0, - html INT NOT NULL default 0, - PRIMARY KEY (path) + weight int NOT NULL default 0, + PRIMARY KEY (path), )"); - - db_query("CREATE INDEX {menu}_fit_idx ON {menu} (fit)"); - db_query("CREATE INDEX {menu}_visible_idx ON {menu} (visible)"); - db_query("CREATE INDEX {menu}_parent_idx ON {menu} (parent)"); - db_query("CREATE INDEX {menu}_pid_idx ON {menu} (parent)"); + db_query("CREATE INDEX {menu_router}_fit_idx ON {menu_router} (fit)"); + db_query("CREATE INDEX {menu_router}_tab_parent_idx ON {menu_router} (tab_parent)"); + + db_query("CREATE TABLE {menu_link} ( + menu_name varchar(64) NOT NULL default '', + mlid int NOT NULL default '0', + plid int NOT NULL default '0', + href varchar(255) NOT NULL default '', + router_path varchar(255) NOT NULL default '', + hidden smallint NOT NULL default '0', + external smallint NOT NULL default '0', + has_children int NOT NULL default '0', + expanded smallint NOT NULL default '0', + weight int NOT NULL default '0', + depth int NOT NULL default '0', + p1 int NOT NULL default '0', + p2 int NOT NULL default '0', + p3 int NOT NULL default '0', + p4 int NOT NULL default '0', + p5 int NOT NULL default '0', + p6 int NOT NULL default '0', + module varchar(255) NOT NULL default 'system', + link_title varchar(255) NOT NULL default '', + options text, + PRIMARY KEY (mlid) + )"); + db_query("CREATE INDEX {menu_link}_parents_idx ON {menu_link} (plid, p1, p2, p3, p4, p5)"); + db_query("CREATE INDEX {menu_link}_menu_name_idx ON {menu_link} (menu_name, href)"); + db_query("CREATE INDEX {menu_link}_expanded_children_idx ON {menu_link} (expanded, has_children)"); db_query("CREATE TABLE {node} ( nid serial CHECK (nid >= 0), @@ -2146,15 +2169,15 @@ function system_update_151() { $num_inserted ++; $node_unalias = db_fetch_array(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $links['link'][$i])); if (isset($node_unalias) && is_array($node_unalias)) { - $link_path = $node_unalias['src']; + $href = $node_unalias['src']; } else { - $link_path = $links['link'][$i]; + $href = $links['link'][$i]; } $mid = db_next_id('{menu}_mid'); $ret[] = update_sql("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) " . - "VALUES ($mid, {$menus[$loop]['pid']}, '" . db_escape_string($link_path) . + "VALUES ($mid, {$menus[$loop]['pid']}, '" . db_escape_string($href) . "', '" . db_escape_string($links['text'][$i]) . "', '" . db_escape_string($links['description'][$i]) . "', 0, 118)"); } diff --git a/modules/system/system.module b/modules/system/system.module index fc884d076..4ba52e8c3 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -399,11 +399,11 @@ function system_main_admin_page($arg = NULL) { 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'); } - - $map = arg(NULL); - $result = db_query("SELECT * FROM {menu} WHERE path LIKE 'admin/%%' AND depth = 2 AND visible = 1 AND path != 'admin/help' ORDER BY mleft"); + $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path + WHERE ml.href like 'admin/%' AND ml.href != 'admin/help' AND ml.depth = 2 AND ml.menu_name = 'navigation' + ORDER BY p1 ASC, p2 ASC, p3 ASC"); while ($item = db_fetch_object($result)) { - _menu_translate($item, $map, MENU_RENDER_LINK); + _menu_link_translate($item); if (!$item->access) { continue; } @@ -423,11 +423,14 @@ function system_main_admin_page($arg = NULL) { * Provide a single block on the administration overview page. */ function system_admin_menu_block($item) { - $map = arg(NULL); $content = array(); - $result = db_query('SELECT * FROM {menu} WHERE depth = %d AND %d < mleft AND mright < %d AND visible = 1 ORDER BY mleft', $item->depth + 1, $item->mleft, $item->mright); + if (!isset($item->mlid)) { + $item->mlid = db_result(db_query("SELECT mlid FROM {menu_links} ml WHERE ml.router_path = '%s' AND menu_name = 'navigation'", $item->path)); + } + $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path + WHERE ml.plid = '%s' AND ml.menu_name = 'navigation' ORDER BY m.weight, m.title", $item->mlid); while ($item = db_fetch_object($result)) { - _menu_translate($item, $map, MENU_RENDER_LINK); + _menu_link_translate($item); if (!$item->access) { continue; } @@ -1657,6 +1660,8 @@ function system_modules_submit($form_values, $form, &$form_state) { $dependencies = NULL; } + // Temporarily disable menu module while it's broken. + unset($form_values['status']['menu']); $enable_modules = array(); $disable_modules = array(); foreach ($form_values['status'] as $key => $choice) { @@ -1700,8 +1705,8 @@ function system_modules_submit($form_values, $form, &$form_state) { if ($old_module_list != $current_module_list) { drupal_rebuild_theme_registry(); - menu_rebuild(); node_types_rebuild(); + menu_rebuild(); drupal_set_message(t('The configuration options have been saved.')); } @@ -2494,14 +2499,14 @@ function theme_admin_block_content($content) { $item['attributes'] = array(); } $item['attributes'] += array('title' => $item['description']); - $output .= '<li class="leaf">'. l($item['title'], $item['path'], $item) .'</li>'; + $output .= '<li class="leaf">'. l($item['title'], $item['href'], $item['options']) .'</li>'; } $output .= '</ul>'; } else { $output = '<dl class="admin-list">'; foreach ($content as $item) { - $output .= '<dt>'. l($item['title'], $item['path'], $item) .'</dt>'; + $output .= '<dt>'. l($item['title'], $item['href'], $item['options']) .'</dt>'; $output .= '<dd>'. $item['description'] .'</dd>'; } $output .= '</dl>'; diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module index 5c290d115..8f1309156 100644 --- a/modules/tracker/tracker.module +++ b/modules/tracker/tracker.module @@ -40,7 +40,6 @@ function tracker_menu() { 'title' => 'My recent posts', 'type' => MENU_LOCAL_TASK, 'access callback' => 'user_is_logged_in', - 'access arguments' => array(1), ); $items['user/%user/track'] = array( diff --git a/modules/user/user.module b/modules/user/user.module index 3b36beba2..73672b741 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -966,10 +966,14 @@ function user_init() { } function user_current_load($arg) { - return user_load($arg); + return $arg ? user_load($arg) : user_load($GLOBALS['user']->uid); } -function user_current_to_arg() { +function user_current_to_arg($arg) { + + if (is_numeric($arg)) { + return $arg; + } return $GLOBALS['user']->uid; } @@ -2034,8 +2038,8 @@ function user_admin_perm_submit($form_values, $form, &$form_state) { drupal_set_message(t('The changes have been saved.')); - // Clear the cached pages and menus: - menu_rebuild(); + // Clear the cached pages + cache_clear_all(); } |