function private_node_grants in Private 5
Same name and namespace in other branches
- 6 private.module \private_node_grants()
- 7.2 private.module \private_node_grants()
- 7 private.module \private_node_grants()
Implementation of hook_node_grants().
Tell the node access system what GIDs the user belongs to for each realm. In this example, we are providing two realms: the example realm, which has just one group id (1) and the user is either a member or not depending upon the operation and the access permission set.
We are also setting up a realm for the node author, though, to give it special privileges. That has 1 GID for every UID, and each user is automatically a member of the group where GID == UID.
File
- ./
private.module, line 84 - This is an example illustrating how to restrict access to nodes based on some criterion associated with the user.
Code
function private_node_grants($account, $op) {
if ($op == 'view' && user_access('access private content', $account)) {
$grants['example'] = array(
1,
);
}
if (($op == 'update' || $op == 'delete') && user_access('edit private content', $account)) {
$grants['example'] = array(
1,
);
}
$grants['example_author'] = array(
$account->uid,
);
return $grants;
}