function book_access_node_access_explain in Book access 6
Same name and namespace in other branches
- 6.2 book_access.module \book_access_node_access_explain()
- 7.2 book_access.module \book_access_node_access_explain()
- 1.x book_access.module \book_access_node_access_explain()
Implements hook_node_access_explain().
hook_node_access_explain() is defined in devel_node_access.module, which helps you to figure out how node access works and what permissions are currently granted.
File
- ./
book_access.module, line 203 - Allows access control for book nodes on a per book basis. It is based on forum_access.module and tac_lite.module.
Code
function book_access_node_access_explain($row) {
static $roles = NULL;
$result = array();
if ($row->realm == 'book_access_role') {
if (!isset($roles)) {
$roles = user_roles();
}
if (isset($roles[$row->gid])) {
$result = array(
t('Grants for users of role %role', array(
'%role' => $roles[$row->gid],
)),
);
}
else {
$result = array(
t('Unknown group ID %gid', array(
'%gid' => $row->gid,
)),
);
}
}
elseif ($row->realm == 'book_access_user') {
if ($user = user_load(array(
'uid' => $row->gid,
))) {
$result = array(
t('Grants for user %username', array(
'%username' => $user->name,
)),
);
}
else {
$result = array(
t('Unknown user ID %gid', array(
'%gid' => $row->gid,
)),
);
}
}
return $result;
}