Commit 2b367df8 authored by Dries's avatar Dries
Browse files

- Patch #41594 by Richard: improved upgrade path of primary and secondary links.

parent ba12462f
...@@ -941,10 +941,19 @@ function system_update_151() { ...@@ -941,10 +941,19 @@ function system_update_151() {
$ret[] = update_sql("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) " . $ret[] = update_sql("INSERT INTO {menu} (mid, pid, path, title, description, weight, type) " .
"VALUES ({$menus[$loop]['pid']}, 0, '', '{$menus[$loop]['menu_name']}', '', 0, 115)"); "VALUES ({$menus[$loop]['pid']}, 0, '', '{$menus[$loop]['menu_name']}', '', 0, 115)");
// Gather links from various settings into a single array.
$phptemplate_links = variable_get("phptemplate_". $menus[$loop]['links_var'], array());
$phptemplate_links_more = variable_get("phptemplate_". $menus[$loop]['links_var'] ."_more", array());
if (isset($ts) && is_array($ts) && is_array($ts[$menus[$loop]['links_var']])) {
$theme_links = $ts[$menus[$loop]['links_var']];
}
else {
$theme_links = array();
}
$links = array_merge($phptemplate_links, $phptemplate_links_more, $theme_links);
// insert all entries from theme links into new menus // insert all entries from theme links into new menus
$num_inserted = 0; $num_inserted = 0;
if (isset($ts) && is_array($ts) && is_array($ts[$menus[$loop]['links_var']])) {
$links = $ts[$menus[$loop]['links_var']];
for ($i = 0; $i < count($links['text']); $i++) { for ($i = 0; $i < count($links['text']); $i++) {
if ($links['text'][$i] != "" && $links['link'][$i] != "") { if ($links['text'][$i] != "" && $links['link'][$i] != "") {
$num_inserted ++; $num_inserted ++;
...@@ -967,7 +976,6 @@ function system_update_151() { ...@@ -967,7 +976,6 @@ function system_update_151() {
if ($loop == 1 && $num_inserted == 0) { if ($loop == 1 && $num_inserted == 0) {
db_query("DELETE FROM {menu} WHERE mid={$menus[$loop]['pid']}"); db_query("DELETE FROM {menu} WHERE mid={$menus[$loop]['pid']}");
} }
}
// set menu_primary_menu variable appropriately // set menu_primary_menu variable appropriately
if (!$ts[$menus[$loop]['toggle_var']] || $num_inserted == 0) { if (!$ts[$menus[$loop]['toggle_var']] || $num_inserted == 0) {
...@@ -976,12 +984,14 @@ function system_update_151() { ...@@ -976,12 +984,14 @@ function system_update_151() {
else { else {
variable_set($menus[$loop]['menu_var'], $menus[$loop]['pid']); variable_set($menus[$loop]['menu_var'], $menus[$loop]['pid']);
} }
variable_del('phptemplate_' .$menus[$loop]['links_var']);
variable_del('phptemplate_'. $menus[$loop]['links_var'] .'_more');
variable_del($menus[$loop]['toggle_var']); variable_del($menus[$loop]['toggle_var']);
unset($ts[$menus[$loop]['toggle_var']]);
variable_del($menus[$loop]['links_var']);
unset($ts[$menus[$loop]['links_var']]);
variable_del($menus[$loop]['more_var']); variable_del($menus[$loop]['more_var']);
unset($ts[$menus[$loop]['more_var']]); // If user has old xtemplate links in a string, leave them in the var.
if (isset($ts) && is_array($ts) && is_array($ts[$menus[$loop]['links_var']])) {
variable_del($menus[$loop]['links_var']);
}
} }
if (isset($ts) && is_array($ts)) { if (isset($ts) && is_array($ts)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment