public static function BookAccess::checkGrant in Book access 6.2
Same name and namespace in other branches
- 7.2 book_access.module \BookAccess::checkGrant()
Checks if a user has access to the book passed as argument.
Parameters
$bid: The ID of the book to check.
$grant: The permission to check for.
$account: The user account for which the permission is checked; if it is not passed, the permission is checked against the current logged in user.
Return value
TRUE if the user has the permission, FALSE otherwise.
3 calls to BookAccess::checkGrant()
- book_access_link_alter in ./
book_access.module - Implements hook_link_alter().
- book_access_outline_access in ./
book_access.module - Determines if the outline tab is accessible.
- book_access_ui_grants_form_access in ./
book_access_ui.module - Determines when the book access tab can be shown in the node edit page.
File
- ./
book_access.module, line 160 - 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 checkGrant($bid, $grant, $account = NULL) {
if (!isset($account)) {
$account = $GLOBALS['user'];
}
$roles = array_keys($account->roles);
$result = db_result(db_query_range("SELECT 1 FROM {book_access_author} WHERE nid = %d AND uid = %d AND grant_{$grant} > 0", $bid, $account->uid, 0, 1)) || db_result(db_query_range("SELECT 1 FROM {book_access_role} WHERE nid = %d AND rid IN (" . db_placeholders($roles) . ") AND grant_{$grant} > 0", array_merge(array(
$bid,
), $roles), 0, 1)) || db_result(db_query_range("SELECT 1 FROM {book_access_user} WHERE nid = %d AND uid = %d AND grant_{$grant} > 0", $bid, $account->uid, 0, 1));
return $result;
}