Active
Project:
Book Manager
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Jul 2011 at 10:33 UTC
Updated:
22 Jul 2011 at 19:59 UTC
I need book manager to enforce personal page access so I changed hook_form_alter() to the following.
Hope somebody else finds it useful.
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
$node = $form['#node'];
if (user_access('add content to personal books') && !(user_access('add content to books') || user_access('administer book outlines'))) {
if (_book_manager_get_book_owner($node->book['bid']) != $user->uid) {
// Destroy the form
$form = NULL;
$form_state['process_input'] = FALSE;
// Return a simple hidden field so that function doesn't fail
$form['book_manager_access'] = array(
'#type' => 'item',
'#value' => t('Only the owner or site administrator can and child pages.'),
);
}
}
if (!isset($form['book_manager_access'])) {
// if the book module did not already add our widgets
if (!isset($form['book']) && user_access('add content to personal books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) {
_book_add_form_elements($form, $node);
}
if (isset($form['book_manager_access'])) {
// if a user has 'administer book outlines' core book may set the book widgets on non-book nodes
// if it does we don't want to mess with what core book did
if (book_type_is_allowed($node->type)) {
// remove any options we need to
_book_manager_outline_alter($form, $node);
}
}
}
}
Comments
Comment #2
mdm commented