From 09c56b4bfc713aa48eced396982cd5a5058c6c13 Mon Sep 17 00:00:00 2001 From: webchick Date: Mon, 4 Jul 2011 22:01:00 -0700 Subject: Issue #1007910 by lyricnz, idflood: Fixed D6->D7 update doesn't convert 'primary-links' menu to 'main-menu'. --- modules/menu/menu.install | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'modules/menu') diff --git a/modules/menu/menu.install b/modules/menu/menu.install index 717c5e712..13cb3cb50 100644 --- a/modules/menu/menu.install +++ b/modules/menu/menu.install @@ -108,6 +108,58 @@ function menu_update_7000() { } } +/** + * Rename "Primary Links" and "Secondary Links" to their Drupal 7 equivalents. + */ +function menu_update_7001() { + // Migrate D6 menu_primary_links_source to D7 menu_main_links_source (without + // renaming). + if (variable_get('menu_primary_links_source') !== NULL) { + variable_set('menu_main_links_source', variable_get('menu_primary_links_source')); + variable_del('menu_primary_links_source'); + } + + // Rename each menu, and any settings that refer to the old menu name. + $rename = array( + 'primary-links' => array('main-menu', 'Main menu'), + 'secondary-links' => array('secondary-menu', 'Secondary menu'), + ); + foreach ($rename as $from_menu => $to) { + list($to_menu, $to_title) = $to; + // Rename the menu, and links in the menu. + db_update('menu_custom') + ->fields(array('menu_name' => $to_menu, 'title' => $to_title)) + ->condition('menu_name', $from_menu) + ->execute(); + db_update('menu_links') + ->fields(array('menu_name' => $to_menu)) + ->condition('menu_name', $from_menu) + ->execute(); + + // Update any content type that used this menu as a default menu. + // Note: these variables may be unset/default, in which case we leave them + // alone. See menu_update_7000() + foreach (_update_7000_node_get_types() as $type => $type_object) { + $menu_options = variable_get('menu_options_' . $type); + if ($menu_options !== NULL) { + variable_set('menu_options_' . $type, str_replace($from_menu, $to_menu, $menu_options)); + if (variable_get('menu_parent_' . $type) == $from_menu . ':0') { + variable_set('menu_parent_' . $type, $to_menu . ':0'); + } + } + } + + // Update the "source for primary links" and "source for secondary links" to + // follow. + if (variable_get('menu_main_links_source') == $from_menu) { + variable_set('menu_main_links_source', $to_menu); + } + if (variable_get('menu_secondary_links_source') == $from_menu) { + variable_set('menu_secondary_links_source', $to_menu); + } + } +} + /** * @} End of "defgroup updates-7.x-extra" * The next series of updates should start at 8000. -- cgit v1.2.3