diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-20 17:54:35 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-20 17:54:35 +0000 |
commit | f4dc86046fb54ec44339eb33f68538fc8019c1b0 (patch) | |
tree | 3c77914ef798a83e7f9dbb27cf556f997d1bf61f /modules/book | |
parent | 580faf849dbd9968aef504f63c297b4b1ccbce78 (diff) | |
download | brdo-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/book')
-rw-r--r-- | modules/book/book.module | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/modules/book/book.module b/modules/book/book.module index 245651d09..3a51bc4c8 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -385,15 +385,12 @@ function _book_parent_select($book_link) { $form['#prefix'] .= '<em>'. t('No book selected.') .'</em>'; } else { - // If the item has children, there is an added limit to the depth of valid parents. - $limit = MENU_MAX_DEPTH - 1 - ($book_link['has_children'] ? menu_link_children_relative_depth($book_link) : 0); - $form = array( '#type' => 'select', '#title' => t('Parent item'), '#default_value' => $book_link['plid'], '#description' => t('The parent page in the book. The maximum depth for a book and all child pages is !maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)), - '#options' => book_toc($book_link['bid'], array($book_link['mlid']), $limit), + '#options' => book_toc($book_link['bid'], array($book_link['mlid']), $book_link['parent_depth_limit']), '#attributes' => array('class' => 'book-title-select'), ); } @@ -422,7 +419,7 @@ function _book_add_form_elements(&$form, $node) { '#tree' => TRUE, '#attributes' => array('class' => 'book-outline-form'), ); - foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid') as $key) { + foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid', 'parent_depth_limit') as $key) { $form['book'][$key] = array( '#type' => 'value', '#value' => $node->book[$key], @@ -442,7 +439,7 @@ function _book_add_form_elements(&$form, $node) { $options = array(); $nid = isset($node->nid) ? $node->nid : 'new'; - if (isset($node->nid) && ($nid == $node->book['original_bid']) && $node->book['has_children'] && (MENU_MAX_DEPTH - 1 - menu_link_children_relative_depth($node->book) == 0)) { + if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) { // This is the top level node in a maximum depth book and thus cannot be moved. $options[$node->nid] = $node->title; } @@ -499,6 +496,10 @@ function book_outline_form(&$form_state, $node) { else { $node->book['original_bid'] = $node->book['bid']; } + // Find the depth limit for the parent select. + if (!isset($node->book['parent_depth_limit'])) { + $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book); + } $form['#node'] = $node; $form['#id'] = 'book-outline'; _book_add_form_elements($form, $node); @@ -901,11 +902,22 @@ function book_nodeapi(&$node, $op, $teaser, $page) { $node->book['original_bid'] = $node->book['bid']; } } + // Find the depth limit for the parent select. + if (isset($node->book['bid']) && !isset($node->book['parent_depth_limit'])) { + $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book); + } break; } } /** + * Find the depth limit for items in the parent select. + */ +function _book_parent_depth_limit($book_link) { + return MENU_MAX_DEPTH - 1 - (($book_link['mlid'] && $book_link['has_children']) ? menu_link_children_relative_depth($book_link) : 0); +} + +/** * Form altering function for the confirm form for a single node deletion. */ function book_form_node_delete_confirm_alter(&$form, $form_state) { |