From 07fc14091e49954d9c26675ba8f2be25a88c5dbf Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Wed, 26 Jul 2017 08:45:10 +0200 Subject: [PATCH] Disable outline information on node types not enabled for book outlines --- modules/book/book.admin.inc | 9 +++++++++ modules/book/book.module | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/book/book.admin.inc b/modules/book/book.admin.inc index 84cbe13..43607dc 100644 --- a/modules/book/book.admin.inc +++ b/modules/book/book.admin.inc @@ -27,6 +27,15 @@ function book_admin_overview() { */ function book_admin_settings() { $types = node_get_types('names'); + + // Patch http://drupal.org/node/502430: + $form['book_restrict_to_types'] = array( + '#type' => 'checkbox', + '#title' => t('Enforce Allowed Types Restrictions'), + '#description' => t('Restrict outline capabilities to only the enabled content types below, even with "administer book outlines" permission.'), + '#default_value' => variable_get('book_restrict_to_types', false), + ); + $form['book_allowed_types'] = array( '#type' => 'checkboxes', '#title' => t('Allowed book outline types'), diff --git a/modules/book/book.module b/modules/book/book.module index 56f839a..fa116b8 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -149,7 +149,10 @@ function book_menu() { * Menu item access callback - determine if the outline tab is accessible. */ function _book_outline_access($node) { - return user_access('administer book outlines') && node_access('view', $node); + // Patch http://drupal.org/node/502430: + $restrict = variable_get('book_restrict_to_types', false); + $types = variable_get('book_allowed_types', array('book')); + return (user_access('administer book outlines') && ((in_array($node->type, $types)) || (!$restrict))) && node_access('update', $node); } /** @@ -286,7 +289,8 @@ function book_form_alter(&$form, $form_state, $form_id) { // Add elements to the node form $node = $form['#node']; - $access = user_access('administer book outlines'); + // Patch http://drupal.org/node/502430: + $access = _book_outline_access($node); if (!$access) { if (user_access('add content to books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) { // Already in the book hierarchy or this node type is allowed