You are here

function book_access_node_access_records in Book access 7.2

Same name and namespace in other branches
  1. 5 book_access.module \book_access_node_access_records()
  2. 6.2 book_access.module \book_access_node_access_records()
  3. 6 book_access.module \book_access_node_access_records()
  4. 1.x book_access.module \book_access_node_access_records()

Implements hook_node_access_records().

Returns a list of grant records for the book node object passed as argument. If we have a book child page, we return the access settings of the top level parent book page node.

File

./book_access.module, line 1092
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_access_records($node) {
  $grants = array();
  if (!empty($node->book['bid'])) {
    $grants = BookAccess::getGrantRecords($node->book['bid']);
    if (is_array($grants) && !$node->status) {

      // unpublished node, grant_view should be off for all types (author,role,user)
      foreach ($grants as &$grant) {
        $grant['grant_view'] = 0;
      }
    }
  }
  return $grants;
}