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