public static function BookAccess::addAuthorGrants in Book access 1.x
Adds author grants to book pages.
Parameters
$bid: The book ID.
$uid: The user ID of the book author.
$grants: An array of grants, in the format
$grants[$grant];
, where
$grant;
is a string between 'grant_view', 'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child', 'grant_edit_outline'.
1 call to BookAccess::addAuthorGrants()
- BookAccess::setAuthorGrants in src/
Access/ BookAccess.php - Sets the author grants for book pages.
File
- src/
Access/ BookAccess.php, line 39 - Allows to set the access control for book nodes on a per book basis.
Class
- BookAccess
- @file
Namespace
Drupal\book_access\AccessCode
public static function addAuthorGrants($bid, $uid, array $grants) {
$row = new stdClass();
$row->nid = $bid;
$row->uid = $uid;
$bool = db_query_range("SELECT 1 FROM {book_access_author} WHERE nid = :nid AND uid = :uid", 0, 1, array(
':nid' => $bid,
':uid' => $uid,
))
->fetchField();
foreach (self::grantIDs() as $id) {
$row->{$id} = !empty($grants[$id]);
}
drupal_write_record('book_access_author', $row, $bool ? array(
'nid',
'uid',
) : array());
}