Disable outline information on node types not enabled for book outlines
This commit is contained in:
parent
8bc400de2a
commit
07fc14091e
2 changed files with 15 additions and 2 deletions
|
@ -27,6 +27,15 @@ function book_admin_overview() {
|
||||||
*/
|
*/
|
||||||
function book_admin_settings() {
|
function book_admin_settings() {
|
||||||
$types = node_get_types('names');
|
$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(
|
$form['book_allowed_types'] = array(
|
||||||
'#type' => 'checkboxes',
|
'#type' => 'checkboxes',
|
||||||
'#title' => t('Allowed book outline types'),
|
'#title' => t('Allowed book outline types'),
|
||||||
|
|
|
@ -149,7 +149,10 @@ function book_menu() {
|
||||||
* Menu item access callback - determine if the outline tab is accessible.
|
* Menu item access callback - determine if the outline tab is accessible.
|
||||||
*/
|
*/
|
||||||
function _book_outline_access($node) {
|
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
|
// Add elements to the node form
|
||||||
$node = $form['#node'];
|
$node = $form['#node'];
|
||||||
|
|
||||||
$access = user_access('administer book outlines');
|
// Patch http://drupal.org/node/502430:
|
||||||
|
$access = _book_outline_access($node);
|
||||||
if (!$access) {
|
if (!$access) {
|
||||||
if (user_access('add content to books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) {
|
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
|
// Already in the book hierarchy or this node type is allowed
|
||||||
|
|
Reference in a new issue