function book_access_node_view_alter in Book access 7.2
Same name and namespace in other branches
- 1.x book_access.module \book_access_node_view_alter()
Implements hook_node_view_alter().
Enables the link "Add child page" only for users who have the right permission.
File
- ./
book_access.module, line 999 - Allows to set the access control for book nodes on a per book basis. Based on forum_access.module and tac_lite.module.
Code
function book_access_node_view_alter(&$build) {
if (!empty($node->book['bid']) && !empty($build['links']['book']['#links'])) {
$links = $build['links']['book']['#links'];
$node = $build['#node'];
if (user_access('administer nodes')) {
return;
}
if (!empty($links['book_add_child'])) {
$bool = (user_access('add content to books') && BookAccess::checkGrant($node->book['bid'], 'add_child') || user_access('administer book outlines')) && node_access('create', variable_get('book_child_type', 'book')) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH;
if (!$bool) {
unset($links['book_add_child']);
}
}
}
}