You are here

function revisioning_user_node_access in Revisioning 6.3

Same name and namespace in other branches
  1. 8 revisioning.module \revisioning_user_node_access()
  2. 6.4 revisioning.module \revisioning_user_node_access()
  3. 7 revisioning.module \revisioning_user_node_access()

Implementation of hook_user_node_access().

Parameters

$revision_op: node or revision operation e.g. 'view revisions'

$node:

Return value

the associated node operation required for this revision_op, or FALSE if access to the node is to be denied. Valid node operations to return are 'view', 'update', 'delete'.

See also

module_grants_node_revision_access()

1 call to revisioning_user_node_access()
_revisioning_node_revision_access in ./revisioning.module
Determine whether the supplied revision operation is permitted on the node. This requires getting through three levels of defence: o Is the operation appropriate for this node at this time, e.g. a node must not be published if it already is or if it…

File

./revisioning.module, line 574
Allows the creation and modification of pre-published as well as live content while the current revision remains unchanged and publicly visible until the changes have been reviewed by a moderator.

Code

function revisioning_user_node_access($revision_op, $node) {
  global $user;
  $type = check_plain($node->type);
  switch ($revision_op) {
    case 'view current':
      break;
    case 'compare to current':
    case 'view revisions':
    case 'view revision list':
      if (user_access('view revisions', $user)) {

        // node.module
        break;
      }
      if (user_access('view revisions of any ' . $type . ' content', $user)) {
        break;
      }
      if ($node->uid == $user->uid && user_access('view revisions of own ' . $type . ' content', $user)) {
        break;
      }
      return FALSE;
    case 'edit current':
      return 'update';
    case 'edit revisions':
    case 'revert revisions':
      return user_access($revision_op, $user) ? 'update' : FALSE;
    case 'publish revisions':
      if (user_access('publish revisions of any ' . $type . ' content', $user)) {
        break;
      }
      if ($node->uid == $user->uid && user_access('publish revisions of own ' . $type . ' content', $user)) {
        break;
      }
    case 'unpublish current revision':
      return user_access($revision_op, $user) ? 'view' : FALSE;
    case 'delete revisions':
    case 'delete archived revisions':
      if (!user_access('delete revisions', $user)) {
        return FALSE;
      }
    case 'delete node':
      return 'delete';
    default:
      drupal_set_message(t("Unknown Revisioning operation '%op'. Treating as 'view'.", array(
        '%op' => $revision_op,
      )), 'warning', FALSE);
  }
  return 'view';
}