summaryrefslogtreecommitdiff
path: root/modules/menu
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-08-20 17:54:35 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-08-20 17:54:35 +0000
commitf4dc86046fb54ec44339eb33f68538fc8019c1b0 (patch)
tree3c77914ef798a83e7f9dbb27cf556f997d1bf61f /modules/menu
parent580faf849dbd9968aef504f63c297b4b1ccbce78 (diff)
downloadbrdo-f4dc86046fb54ec44339eb33f68538fc8019c1b0.tar.gz
brdo-f4dc86046fb54ec44339eb33f68538fc8019c1b0.tar.bz2
#165675 follow up patch by pwolanin: retain menu information on node previews to check, do not use the newly selected values yet, to be consistent with the DB
Diffstat (limited to 'modules/menu')
-rw-r--r--modules/menu/menu.module20
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index f9ad1a31c..385732482 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -403,7 +403,12 @@ function menu_edit_item_submit($form, &$form_state) {
function menu_parent_options($menus, $item) {
// If the item has children, there is an added limit to the depth of valid parents.
- $limit = MENU_MAX_DEPTH - 1 - (($item['mlid'] && $item['has_children']) ? menu_link_children_relative_depth($item) : 0);
+ if (isset($item['parent_depth_limit'])) {
+ $limit = $item['parent_depth_limit'];
+ }
+ else {
+ $limit = _menu_parent_depth_limit($item);
+ }
foreach ($menus as $menu_name => $title) {
$tree = menu_tree_all_data($menu_name, NULL);
@@ -729,11 +734,22 @@ function menu_nodeapi(&$node, $op) {
// Set default values.
$node->menu = $item + array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu_name, 'weight' => 0, 'options' => array(), 'module' => 'menu', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0, 'customized' => 0);
}
+ // Find the depth limit for the parent select.
+ if (!isset($node->menu['parent_depth_limit'])) {
+ $node->menu['parent_depth_limit'] = _menu_parent_depth_limit($node->menu);
+ }
break;
}
}
/**
+ * Find the depth limit for items in the parent select.
+ */
+function _menu_parent_depth_limit($item) {
+ return MENU_MAX_DEPTH - 1 - (($item['mlid'] && $item['has_children']) ? menu_link_children_relative_depth($item) : 0);
+}
+
+/**
* Implementation of hook_form_alter(). Adds menu item fields to the node form.
*/
function menu_form_alter(&$form, $form_state, $form_id) {
@@ -764,7 +780,7 @@ function menu_form_alter(&$form, $form_state, $form_id) {
$form['menu']['#collapsed'] = TRUE;
}
- foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden') as $key) {
+ foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden', 'parent_depth_limit') as $key) {
$form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]);
}