You are here

function revisioning_node_access in Revisioning 7

Same name and namespace in other branches
  1. 8 revisioning.module \revisioning_node_access()

Implements hook_node_access().

This gets invoked from node.module/node_access() after it has checked the standard node permissions using node_node_access() and just before it checks the node_access grants table. We basically return "don't care" except for one 'view' case, which replicates the node.module. "Don't care" in this case would result in "access denied".

File

./revisioning.module, line 980
Allows content to be updated and reviewed before submitting it for publication, while the current live revision remains unchanged and publicly visible until the changes have been reviewed and found fit for publication by a moderator.

Code

function revisioning_node_access($node, $node_op, $account) {

  // Taken from node.module/node_access():
  // If no modules implement hook_node_grants(), the default behaviour is to
  // allow all users to view published nodes, so reflect that here,
  // augmented for the 'view revisions' family of permissions, which apply to
  // both published and unpublished nodes.
  if ($node_op == 'view' && !module_implements('node_grants')) {
    if ($node->status == NODE_PUBLISHED || !empty($node->revision_moderation) && revisioning_user_node_access('view revisions', $node, $account)) {
      return NODE_ACCESS_ALLOW;
    }
  }

  // [#1492246]
  // Deny access to unpublished, moderated content by anonymous users.
  if (empty($node->status) && !empty($node->revision_moderation) && empty($account->uid)) {
    return NODE_ACCESS_DENY;
  }
  return NODE_ACCESS_IGNORE;
}