You are here

public static function BookAccess::updateGrants in Book access 7.2

Same name and namespace in other branches
  1. 6.2 book_access.module \BookAccess::updateGrants()

Updates the grants for a book.

Parameters

$bid: The book ID.

$fields: The fields to update.

$types: An array containing the grant types; the currently used values are 'author', 'role', 'user'. It is responsibility of the caller to use values for $types for which $field is valid.

File

./book_access.module, line 764
Allows to set the access control for book nodes on a per book basis. Based on forum_access.module and tac_lite.module.

Class

BookAccess
@file

Code

public static function updateGrants($bid, array $fields, array $types = array(
  'author',
  'role',
  'user',
)) {
  foreach ($types as $type) {
    switch ($type) {
      case 'author':
      case 'role':
      case 'user':
        $table = "book_access_{$type}";
        break;
      default:
        $table = '';
    }
    if ($table) {
      db_update($table)
        ->fields($fields)
        ->condition('nid', $bid)
        ->execute();
    }
  }
}