public static function BookAccess::addRoleGrants in Book access 6.2
Same name and namespace in other branches
- 7.2 book_access.module \BookAccess::addRoleGrants()
Adds role grants to book pages.
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::addRoleGrants()
- BookAccess::setRoleGrants in ./
book_access.module - Sets the role grants for book pages.
File
- ./
book_access.module, line 66 - 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 addRoleGrants($bid, array $rids, array $grants) {
$row = new stdClass();
$row->nid = $bid;
foreach ($rids as $rid) {
$row->rid = $rid;
$bool = db_result(db_query_range("SELECT 1 FROM {book_access_role} WHERE nid = %d AND rid = %d", $bid, $rid, 0, 1));
foreach (self::grantIDs() as $id) {
$row->{$id} = !empty($grants[$id][$rid]);
}
drupal_write_record('book_access_role', $row, $bool ? array(
'nid',
'rid',
) : array());
}
}