function private_node_grants in Private 6
Same name and namespace in other branches
- 5 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 71 - A tremendously simple access control module -- it allows users to mark individual nodes as private; users with 'access private content' perms can read these nodes, while others cannot.
Code
function private_node_grants($account, $op) {
if ($op == 'view' && user_access('access private content', $account)) {
$grants['private'] = array(
1,
);
}
if (($op == 'update' || $op == 'delete') && user_access('edit private content', $account)) {
$grants['private'] = array(
1,
);
}
$grants['private_author'] = array(
$account->uid,
);
return $grants;
}