diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-03-14 15:36:25 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-03-14 15:36:25 +0000 |
commit | e74aa7eeb62f0db82215e24b9a1a70bc43f01cd7 (patch) | |
tree | a44b064ee4d7463ab59101d3541ff3f6b48846a2 /modules/book.module | |
parent | a70522881e3b32483a1d0905683c1537c80b1e8d (diff) | |
download | brdo-e74aa7eeb62f0db82215e24b9a1a70bc43f01cd7.tar.gz brdo-e74aa7eeb62f0db82215e24b9a1a70bc43f01cd7.tar.bz2 |
#53956: Don't allow moving away top-level book pages if you cannot move them back.
Diffstat (limited to 'modules/book.module')
-rw-r--r-- | modules/book.module | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/modules/book.module b/modules/book.module index bdd28415b..fca2c28a3 100644 --- a/modules/book.module +++ b/modules/book.module @@ -247,13 +247,18 @@ function book_validate($node) { * Implementation of hook_form(). */ function book_form(&$node) { - $form['parent'] = array('#type' => 'select', - '#title' => t('Parent'), - '#default_value' => ($node->parent ? $node->parent : arg(4)), - '#options' => book_toc($node->nid, $node->parent), - '#weight' => -4, - '#description' => user_access('create new books') ? t('The parent section in which to place this page. Note that each page whose parent is <top-level> is an independent, top-level book.') : t('The parent that this page belongs in.'), - ); + if ($node->nid && !$node->parent && !user_access('create new books')) { + $form['parent'] = array('#type' => 'value', $node->parent); + } + else { + $form['parent'] = array('#type' => 'select', + '#title' => t('Parent'), + '#default_value' => ($node->parent ? $node->parent : arg(4)), + '#options' => book_toc($node->nid), + '#weight' => -4, + '#description' => user_access('create new books') ? t('The parent section in which to place this page. Note that each page whose parent is <top-level> is an independent, top-level book.') : t('The parent that this page belongs in.'), + ); + } $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), @@ -306,7 +311,7 @@ function book_outline($nid) { $form['parent'] = array('#type' => 'select', '#title' => t('Parent'), '#default_value' => $page->parent, - '#options' => book_toc($node->nid, $page->parent), + '#options' => book_toc($node->nid), '#description' => t('The parent page in the book.'), ); $form['weight'] = array('#type' => 'weight', @@ -557,7 +562,7 @@ function book_toc_recurse($nid, $indent, $toc, $children, $exclude) { /** * Returns an array of titles and nid entries of book pages in table of contents order. */ -function book_toc($exclude, $parent) { +function book_toc($exclude = 0) { $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 ORDER BY b.weight, n.title')); while ($node = db_fetch_object($result)) { @@ -569,7 +574,7 @@ function book_toc($exclude, $parent) { $toc = array(); // If the user has permission to create new books, add the top-level book page to the menu; - if (user_access('create new books') || ($exclude && !$parent)) { + if (user_access('create new books')) { $toc[0] = '<'. t('top-level') .'>'; } |