You are here

function book_access_link_alter in Book access 6

Same name and namespace in other branches
  1. 6.2 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 124
Allows 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) {
  global $user;
  if (user_access('administer nodes')) {
    return;
  }
  if (!empty($node->book['bid']) && !empty($links['book_add_child'])) {
    $bool = (user_access('add content to books') && book_access_grant_check($node->book['bid'], 'update') || 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']);
    }
  }
}