You are here

function book_access_node_view in Book access 7.2

Same name and namespace in other branches
  1. 1.x book_access.module \book_access_node_view()

Implements hook_node_view().

We want to hide the "Add Child Page" link if the current user doesn't have permission for it.

File

./book_access.module, line 1139
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($node, $view_mode, $langcode) {
  if (isset($node->content['links']['book']) && isset($node->content['links']['book']['#links']['book_add_child'])) {
    if (!BookAccess::checkGrant($node->book['bid'], 'grant_add_child')) {
      unset($node->content['links']['book']['#links']['book_add_child']);
    }
  }
}