You are here

function _revisioning_operation_appropriate in Revisioning 6.4

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

Test whether the supplied revision operation is appropriate for the node. This is irrespective of user permissions, e.g. even for an administrator it doesn't make sense to publish a node that is already published or to "revert" to the current revision.

Parameters

$revision_op:

$node:

Return value

TRUE if the operation is appropriate for this node at this point

1 call to _revisioning_operation_appropriate()
_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 578
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_operation_appropriate($revision_op, $node) {
  switch ($revision_op) {
    case 'compare to current':

    // Can't compare against itself
    case 'delete revisions':

      // If the revision is the current one, suppress the delete operation
      // @TODO ...unless it's the only revision, in which case delete the
      // entire node; however this requires a different URL.
      return !$node->is_current;
    case 'view revision list':

      // i.e. node revisions summary
      if ($node->num_revisions == 1 && !$node->revision_moderation) {

        // Suppress Revisions tab when when there's only 1 revision -- consistent with core.
        // However, when content is moderated (i.e. "New revision in draft,
        // pending moderation" is ticked) we want to be able to get to the
        // 'Unpublish current' link on this page and the 'Publish this' tab on
        // the next. Also when user has permission to delete node, we need to
        // present the Delete link, unless we assume that this privilege
        // assumes the 'edit' permission.
        return FALSE;
      }
      break;
    case 'publish revisions':

      // If the node isn't meant to be moderated or the revision is not either
      // pending or current but not published, then disallow publication.
      if (!$node->revision_moderation || !($node->is_pending || $node->is_current && !$node->status)) {
        return FALSE;
      }
      break;
    case 'unpublish current revision':

      // If the node isn't meant to be moderated, or it is unpublished already
      // or we're not looking at the current revision, then unpublication is off.
      if (!$node->revision_moderation || !$node->status || !$node->is_current) {
        return FALSE;
      }
      break;
    case 'revert revisions':

      // If this revision is pending or current, suppress the reversion
      if ($node->is_pending || $node->is_current) {
        return FALSE;
      }
      break;
  }
  return TRUE;
}