You are here

public static function BookAccess::setRoleGrants in Book access 1.x

Sets the role grants for book pages.

The method delete the role grants before to set the new ones.

Parameters

$bid: The book ID.

$rids: An array of role IDs for which to add the book grants.

$grants: An array of grants, in the format

$grants[$grant][$rid];

, where

$grant;

is a string between 'grant_view', 'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child', 'grant_edit_outline', and

$rid;

is the role ID.

1 call to BookAccess::setRoleGrants()
BookAccess::resetToDefault in src/Access/BookAccess.php
Resets book permissions to its defaults, ignoring user-specific ones.

File

src/Access/BookAccess.php, line 636
Allows to set the access control for book nodes on a per book basis.

Class

BookAccess
@file

Namespace

Drupal\book_access\Access

Code

public static function setRoleGrants($bid, array $rids, array $grants) {
  db_delete('book_access_role')
    ->condition('nid', $bid)
    ->execute();
  self::addRoleGrants($bid, $rids, $grants);
}