function nodeaccess_node_access in Nodeaccess 7
Same name and namespace in other branches
- 8.2 nodeaccess.module \nodeaccess_node_access()
- 8 nodeaccess.module \nodeaccess_node_access()
Implements hook_node_access().
Parameters
$node:
$op:
$account:
Return value
string
File
- ./
nodeaccess.module, line 108 - Provide per node access control
Code
function nodeaccess_node_access($node, $op, $account) {
switch ($op) {
case 'update':
case 'delete':
if (!isset($account->uid)) {
global $user;
$account = $user;
}
// If the node belongs to a deleted user.
if ($account->uid == 0 && $node->uid == 0) {
$grants = nodeaccess_get_grants($node);
// We check if the role has particular access to this node.
// If anonymous has rights to this node, we allow them.
if (!empty($grants['rid'][DRUPAL_ANONYMOUS_RID]['grant_update']) && $op == 'update' || !empty($grants['rid'][DRUPAL_ANONYMOUS_RID]['grant_delete']) && $op == 'delete') {
return NODE_ACCESS_ALLOW;
}
return NODE_ACCESS_DENY;
}
break;
}
}