public static function BookAccess::getUserGrants in Book access 1.x
Returns the user book grants.
Parameters
$bid: The book ID.
$uids: The variables where to store the user IDs.
$defaults: An array containing the default values for the grants.
Return value
An array of grants, in the format
$grants[$grant][$uid];
, where
$grant;
is a string between 'grant_view', 'grant_update', 'grant_delete', 'grant_admin_access', 'grant_add_child', 'grant_edit_outline', and
$uid;
is the user ID.
File
- src/
Access/ BookAccess.php, line 544 - 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 getUserGrants($bid, &$uids) {
$grants = array(
'grant_view' => array(),
'grant_update' => array(),
'grant_delete' => array(),
'grant_admin_access' => array(),
'grant_add_child' => array(),
'grant_edit_outline' => array(),
);
$uids = array();
$result = db_query("SELECT * FROM {book_access_user} bau INNER JOIN {users} u ON u.uid = bau.uid WHERE bau.nid = :nid", array(
':nid' => $bid,
));
foreach ($result as $access) {
$uid = $access->uid;
$uids[$uid] = $uid;
foreach (self::grantIDs() as $id) {
$grants[$id][$uid] = !empty($access->{$id});
}
}
return $grants;
}