You are here

function _revisioning_publish_latest_revision in Revisioning 7

Same name and namespace in other branches
  1. 8 revisioning_api.inc \_revisioning_publish_latest_revision()
  2. 6.4 revisioning_api.inc \_revisioning_publish_latest_revision()
  3. 6.3 revisioning_api.inc \_revisioning_publish_latest_revision()

Publish latest revision.

Find the most recent pending revision, make it current, unless it already is and publish it and its node.

Note that no check is made as to whether the initiating user has permission to publish this node.

Note that this is a post-save operation that should not be called in response to hook_node_presave(), as invoked from node_save().

Parameters

object $node: The node object whose latest pending revision is to be published

Return value

bool TRUE if operation was successful, FALSE if there is no pending revision to publish

2 calls to _revisioning_publish_latest_revision()
revisioning_publish_latest_revision_action in ./revisioning_triggers_actions.inc
As declared in revisioning_action_info().
revisioning_rules_action_publish_latest in ./revisioning.rules.inc
Action: publish most recent pending revision.

File

./revisioning_api.inc, line 591
API functions of Revisioning module

Code

function _revisioning_publish_latest_revision(&$node) {

  // Get the latest pending revision.
  $pending_revisions = _revisioning_get_pending_revisions($node->nid);
  $latest_pending = array_shift($pending_revisions);
  if ($latest_pending) {
    $node_revision = node_load($node->nid, $latest_pending->vid);
    _revisioning_publish_revision($node_revision);
    return TRUE;
  }

  // If there is no pending revision, take the current revision, provided it is
  // NOT published.
  if (!$node->status) {
    if (!isset($node->is_current)) {
      $node->current_revision_id = revisioning_get_current_node_revision_id($node->nid);
      $node->is_current = revisioning_revision_is_current($node);
    }
    if ($node->is_current) {
      _revisioning_publish_revision($node);
      return TRUE;
    }
  }
  return FALSE;
}