You are here

public static function BookAccess::updateGrants in Book access 6.2

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

Updates the grants for a book.

Parameters

$bid: The book ID.

$field: The field to update.

$value: The value to set for the field.

$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.

1 call to BookAccess::updateGrants()
book_access_nodeapi in ./book_access.module
Implements hook_nodeapi().

File

./book_access.module, line 597
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.

Class

BookAccess
@file

Code

public static function updateGrants($bid, $field, $value, 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_query("UPDATE {" . $table . "} SET {$field} = %d WHERE nid = %d", $value, $bid);
    }
  }
}