diff --git a/modules/book/book.module b/modules/book/book.module index e501c60..739a3e8 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -78,7 +78,7 @@ function book_menu() { 'title' => 'Books', 'description' => "Manage your site's book outlines.", 'page callback' => 'book_admin_overview', - 'access arguments' => array('administer book outlines'), + 'access arguments' => array('administer site configuration'), 'file' => 'book.admin.inc', ); $items['admin/content/book/list'] = array( @@ -191,7 +191,7 @@ function book_block($op = 'list', $delta = 0, $edit = array()) { $block['subject'] = t('Book navigation'); $book_menus = array(); $pseudo_tree = array(0 => array('below' => FALSE)); - foreach (book_get_books() as $book_id => $book) { + foreach (book_get_books($node->type) as $book_id => $book) { if ($book['bid'] == $current_bid) { // If the current page is a node associated with a book, the menu // needs to be retrieved. @@ -255,7 +255,7 @@ function theme_book_title_link($link) { * This list may be used for generating a list of all the books, or for building * the options for a form select. */ -function book_get_books() { +function book_get_books($type = null) { static $all_books; if (!isset($all_books)) { @@ -268,9 +268,11 @@ function book_get_books() { if ($nids) { $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, ml.link_title")); while ($link = db_fetch_array($result2)) { - $link['href'] = $link['link_path']; - $link['options'] = unserialize($link['options']); - $all_books[$link['bid']] = $link; + if (!isset($type) || !variable_get('book_restrict_to_types', false) || $link['type'] == $type) { + $link['href'] = $link['link_path']; + $link['options'] = unserialize($link['options']); + $all_books[$link['bid']] = $link; + } } } } @@ -401,7 +403,7 @@ function _book_add_form_elements(&$form, $node) { $options[$node->nid] = $node->title; } else { - foreach (book_get_books() as $book) { + foreach (book_get_books($node->type) as $book) { $options[$book['nid']] = $book['title']; } } @@ -560,7 +562,8 @@ function book_prev($book_link) { // The previous page in the book may be a child of the previous visible link. if ($prev['depth'] == $book_link['depth'] && $prev['has_children']) { // The subtree will have only one link at the top level - get its data. - $data = array_shift(book_menu_subtree_data($prev)); + $subtree_data = book_menu_subtree_data($prev); + $data = array_shift($subtree_data); // The link of interest is the last child - iterate to find the deepest one. while ($data['below']) { $data = end($data['below']);