function forum_access_node_access in Forum Access 7
Same name and namespace in other branches
- 8 forum_access.module \forum_access_node_access()
Implements hook_node_access().
1 call to forum_access_node_access()
- _forum_access_node_view_alter in ./
forum_access.node.inc - Really implements hook_node_view_alter().
File
- ./
forum_access.module, line 610 - forum_access.module
Code
function forum_access_node_access($node, $op, $account) {
$cache =& drupal_static(__FUNCTION__, array());
$type = is_string($node) ? $node : $node->type;
if ($op == 'create') {
if ($type == 'forum') {
$tid = forum_access_current_tid();
if (isset($cache[$account->uid][$op][$tid])) {
return $cache[$account->uid][$op][$tid];
}
if (!forum_access_access('create', $tid, $account)) {
return $cache[$account->uid][$op][$tid] = NODE_ACCESS_DENY;
}
return $cache[$account->uid][$op][$tid] = NODE_ACCESS_IGNORE;
}
}
else {
$nid = $node->nid;
if (!isset($cache[$account->uid][$op][$nid])) {
if ($tid = _forum_access_get_tid($node)) {
if (!forum_access_access('view', $tid, $account)) {
return $cache[$account->uid][$op][$nid] = NODE_ACCESS_DENY;
}
if ($op == 'update' && (user_access('edit any forum content', $account) || $node->uid == $account->uid && user_access('edit own forum content', $account)) || $op == 'delete' && (user_access('delete any forum content', $account) || $node->uid == $account->uid && user_access('delete own forum content', $account))) {
return $cache[$account->uid][$op][$nid] = forum_access_node_access($node, 'view', $account);
}
$access = forum_access_access($op, $tid, $account);
if ($op == 'view' && $access == 1 && !$node->status) {
if (user_access('view own unpublished content', $account) && $account->uid && $account->uid == $node->uid) {
// Allow access to own unpublished node.
}
elseif (forum_access_is_moderator($account, $tid)) {
// Allow access to moderator.
}
else {
$access = FALSE;
}
}
return $cache[$account->uid][$op][$nid] = $access ? NODE_ACCESS_IGNORE : NODE_ACCESS_DENY;
}
else {
return $cache[$account->uid][$op][$nid] = NODE_ACCESS_IGNORE;
}
}
return $cache[$account->uid][$op][$nid];
}
return NODE_ACCESS_IGNORE;
}