Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.431
diff -u -p -r1.431 book.module
--- modules/book/book.module	7 Aug 2007 11:43:05 -0000	1.431
+++ modules/book/book.module	9 Aug 2007 02:02:35 -0000
@@ -396,12 +396,15 @@ 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.'),
-      '#options' => book_toc($book_link['bid'], array($book_link['mlid'])),
+      '#options' => book_toc($book_link['bid'], array($book_link['mlid']), $limit),
     );
   }
   return $form;
@@ -963,12 +966,12 @@ function theme_book_navigation($book_lin
 /**
  * A recursive helper function for book_toc().
  */
-function _book_toc_recurse($tree, $indent, &$toc, $exclude) {
+function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
   foreach ($tree as $data) {
     if (!in_array($data['link']['mlid'], $exclude)) {
       $toc[$data['link']['mlid']] = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
-      if ($data['below'] && $data['link']['depth'] < MENU_MAX_DEPTH - 1) {
-        _book_toc_recurse($data['below'], $indent .'--', $toc, $exclude);
+      if ($data['below'] && $data['link']['depth'] < $depth_limit) {
+        _book_toc_recurse($data['below'], $indent .'--', $toc, $exclude, $depth_limit);
       }
     }
   }
@@ -982,14 +985,16 @@ function _book_toc_recurse($tree, $inden
  * @param $exclude
  *   Optional array of mlid values.  Any link whose mlid is in this array
  *   will be excluded (along with its children).
+ * @param $depth_limit
+ *   Any link deeper than this value will be excluded (along with its children).
  * @return
  *   An array of mlid, title pairs for use as options for selecting a book page.
  */
-function book_toc($bid, $exclude = array()) {
+function book_toc($bid, $exclude = array(), $depth_limit) {
 
   $tree = menu_tree_all_data(book_menu_name($bid));
   $toc = array();
-  _book_toc_recurse($tree, '', $toc, $exclude);
+  _book_toc_recurse($tree, '', $toc, $exclude, $depth_limit);
 
   return $toc;
 }
