public static function BookAccess::getAuthorGrants in Book access 1.x
Returns the book author grants.
Parameters
$bid: The book ID.
$uid: The user ID for the book author.
$defaults: An array containing the default values for the grants.
Return value
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'.
File
- src/
Access/ BookAccess.php, line 326 - 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 getAuthorGrants($bid, $uid, array $defaults = array()) {
$grants = db_query_range('SELECT * FROM {book_access_author} WHERE nid = :nid AND uid = :uid', 0, 1, array(
':nid' => $bid,
':uid' => $uid,
))
->fetchAssoc();
if (!$grants) {
$defaults = array_filter($defaults);
foreach (self::grantIDs() as $id) {
$grants[$id] = !empty($defaults[$id]);
}
}
return $grants;
}