function ack_node_node_access in Access Control Kit 7
Implements hook_node_access().
File
- ack_node/
ack_node.module, line 85 - The ACK node module.
Code
function ack_node_node_access($node, $op, $account) {
$type = is_string($node) ? $node : $node->type;
if (in_array($type, node_permissions_get_configured_types())) {
if ($op == 'create' && user_access('ack create ' . $type . ' content', $account)) {
// The user must have the permission in at least one realm, in any scheme,
// in order to exercise that permission to create a node.
foreach (access_user_permission_realms('ack create ' . $type . ' content', $account) as $realms) {
if (!empty($realms)) {
return NODE_ACCESS_ALLOW;
}
}
}
if ($op == 'update') {
if (access_user_object_access('ack edit any ' . $type . ' content', 'node', $node, $account) || access_user_object_access('ack edit own ' . $type . ' content', 'node', $node, $account) && $account->uid == $node->uid) {
return NODE_ACCESS_ALLOW;
}
}
if ($op == 'delete') {
if (access_user_object_access('ack delete any ' . $type . ' content', 'node', $node, $account) || access_user_object_access('ack delete own ' . $type . ' content', 'node', $node, $account) && $account->uid == $node->uid) {
return NODE_ACCESS_ALLOW;
}
}
}
// Returning nothing from this function would have the same effect.
return NODE_ACCESS_IGNORE;
}