# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: modules/menu/menu.module --- modules/menu/menu.module Base (1.233) +++ modules/menu/menu.module Locally Modified (Based On 1.233) @@ -314,8 +314,10 @@ * @param $menus * An array of menu names and titles, such as from menu_get_menus(). * @param $item - * The menu item or the node type for which to generate a list of parents. + * The menu item for which to generate a list of parents. * If $item['mlid'] == 0 then the complete tree is returned. + * @param $type + * The node type for which to generate a list of parents. * @return * An array of menu link titles keyed on the a string containing the menu name * and mlid. The list excludes the given item and its children. @@ -323,7 +325,7 @@ * @todo This has to be turned into a #process form element callback. The * 'menu_override_parent_selector' variable is entirely superfluous. */ -function menu_parent_options($menus, $item) { +function menu_parent_options($menus, $item, $type = '') { // The menu_links table can be practically any size and we need a way to // allow contrib modules to provide more scalable pattern choosers. // hook_form_alter is too late in itself because all the possible parents are @@ -333,18 +335,17 @@ } $available_menus = array(); - if (is_array($item)) { - // If $item is an array fill it with all menus given to this function. + + if (empty($type)) { + // If $item is a node type, get all available menus for this type. $available_menus = $menus; } else { - // If $item is a node type, get all available menus for this type and - // prepare a dummy menu item for _menu_parent_depth_limit(). - $type_menus = variable_get('menu_options_' . $item, array('main-menu' => 'main-menu')); + // If a node type is set limit the available menu options. + $type_menus = variable_get('menu_options_' . $type, array('main-menu' => 'main-menu')); foreach ($type_menus as $menu) { $available_menus[$menu] = $menu; } - $item = array('mlid' => 0); } return _menu_get_options($menus, $available_menus, $item); @@ -589,15 +590,18 @@ * @see menu_node_submit() */ function menu_form_node_form_alter(&$form, $form_state) { - // Generate a list of possible parents. + // Generate a list of possible parents (not including this link or descendants). // @todo This must be handled in a #process handler. + $link = array('mlid' => 0); + if($form['#node']->menu['mlid']) { + $link = $form['#node']->menu; + } $type = $form['#node']->type; - $options = menu_parent_options(menu_get_menus(), $type); + $options = menu_parent_options(menu_get_menus(), $link, $type); // If no possible parent menu items were found, there is nothing to display. if (empty($options)) { return; } - $link = $form['#node']->menu; $form['menu'] = array( '#type' => 'fieldset', @@ -648,9 +652,9 @@ ); $default = ($link['mlid'] ? $link['menu_name'] . ':' . $link['plid'] : variable_get('menu_parent_' . $type, 'main-menu:0')); - // @todo This will fail with the new selective menus per content type. + // @todo If the current parent menu item is not present in options, user should not be allowed to access menu link settings. if (!isset($options[$default])) { - $default = 'navigation:0'; + $default = reset(array_keys($options)); } $form['menu']['link']['parent'] = array( '#type' => 'select',