book_access.api.php in Book access 1.x
Same filename and directory in other branches
Hooks provided by the Book access module.
File
book_access.api.phpView source
<?php
/**
* @file
* Hooks provided by the Book access module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Allows other modules to change the author access permissions for a book.
*
* @param array $grants
* The array of the grants, in the format @code $grants[$grant] @endcode.
* @param array $context
* An array containing two indexes:
* - the book ID (bid)
* - the node for the book page (node)
*/
function hook_book_access_author_grants_alter(array &$grants, array $context) {
$node = $context['node'];
if ($node->uid == 1) {
$grants['grant_view'] = TRUE;
$grants['grant_update'] = TRUE;
$grants['grant_delete'] = TRUE;
}
}
/**
* Allows other modules to change the users access permissions for a book.
*
* @param array $rids
* The array containing the list of the role IDs, as returned by
* user_roles().
* @param array $grants
* The array of the grants in the format @code $grants[$grant][$rid] @endcode.
* @param array $context
* An array containing two indexes:
* - the book ID (bid)
* - the node for the book page (node)
*/
function hook_book_access_roles_grants_alter(array &$rids, array &$grants, array $context) {
if (isset($rids[\Drupal\Core\Session\AccountInterface::AUTHENTICATED_RID])) {
$grants['grant_view'][\Drupal\Core\Session\AccountInterface::AUTHENTICATED_RID] = TRUE;
$grants['grant_update'][\Drupal\Core\Session\AccountInterface::AUTHENTICATED_RID] = TRUE;
$grants['grant_delete'][\Drupal\Core\Session\AccountInterface::AUTHENTICATED_RID] = TRUE;
}
}
/**
* Allows other modules to change the roles access permissions for a book.
*
* @param array $uids
* The array containing the list of the user IDs.
* @param array $grants
* The array of the grants in the format @code $grants[$grant][$uid] @endcode.
* @param array $context
* An array containing two indexes:
* - the book ID (bid)
* - the node for the book page (node)
*/
function hook_book_access_users_grants_alter(array &$uids, array &$grants, array $context) {
if (isset($uids[1])) {
$grants['grant_view'][1] = TRUE;
$grants['grant_update'][1] = TRUE;
$grants['grant_delete'][1] = TRUE;
}
}
/**
* @} End of "addtogroup hooks".
*/
Functions
Name | Description |
---|---|
hook_book_access_author_grants_alter | Allows other modules to change the author access permissions for a book. |
hook_book_access_roles_grants_alter | Allows other modules to change the users access permissions for a book. |
hook_book_access_users_grants_alter | Allows other modules to change the roles access permissions for a book. |