You are here

function revisioning_publish_latest_revision in Revisioning 6

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

Parameters

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

1 call to revisioning_publish_latest_revision()
revisioning_publish_latest_revision_action in ./revisioning_triggers_actions.inc
Implementation of publish_latest_revision action

File

./revisioning.module, line 319

Code

function revisioning_publish_latest_revision($node) {

  // Get latest pending revision or take the current provided it's UNpublished
  $latest_pending = array_shift(_get_pending_revisions($node->nid));
  if (!$latest_pending) {
    $current_revision = _get_current_revision($node->nid);
    if ($node->vid == $current_revision->vid && !$node->status) {
      $latest_pending = $node;
    }
  }
  if ($latest_pending) {
    _revisioning_publish_revision($node->nid, $latest_pending->vid, $latest_pending->title, $latest_pending->type);
  }
  else {
    drupal_set_message(t('"!title" has no pending revision to be published.', array(
      '!title' => $node->title,
    )), 'warning');
  }
}