function internal_nodes_node_access in Internal Nodes 7
Implements hook_node_access().
Could/should this functionality be implemented in internal_nodes_force_404()?
File
- ./
internal_nodes.module, line 134 - Internal nodes
Code
function internal_nodes_node_access($node, $op, $account) {
if ($op == 'view') {
// Check if user doesn't have access and we are viewing the node view alone.
if (!user_access('access ' . $node->type . ' node view', $account) && arg(0) == 'node' && arg(1) == $node->nid) {
// If user has permission to edit node AND arg(2) == 'edit', allow access
// Note: node_access() use would cause an infinite loop.
if ((user_access('edit own ' . $node->type . ' content', $account) || user_access('edit any ' . $node->type . ' content', $account)) && arg(2) == 'edit') {
return NODE_ACCESS_IGNORE;
}
// If user has permission to delete node AND arg(2) == 'delete', allow access
if ((user_access('delete own ' . $node->type . ' content', $account) || user_access('delete any ' . $node->type . ' content', $account)) && arg(2) == 'delete') {
return NODE_ACCESS_IGNORE;
}
// Check the action
switch ($node->internal_nodes['action']) {
case INTERNAL_NODES_ACCESS_DENIED:
if (module_exists('rules')) {
rules_invoke_event('internal_nodes_denied', $node);
}
// Access denied
return NODE_ACCESS_DENY;
case INTERNAL_NODES_REDIRECT:
if (module_exists('rules')) {
rules_invoke_event('internal_nodes_denied', $node);
}
// Redirect
$redirect = internal_nodes_create_redirect($node->internal_nodes['url'], $node);
drupal_goto($redirect['path'], $redirect['options'], 301);
break;
default:
break;
}
}
}
return NODE_ACCESS_IGNORE;
}