You are here

function _revisioning_publish_revision in Revisioning 6.3

Same name and namespace in other branches
  1. 8 revisioning_api.inc \_revisioning_publish_revision()
  2. 6.4 revisioning_api.inc \_revisioning_publish_revision()
  3. 6 revisioning.module \_revisioning_publish_revision()
  4. 7 revisioning_api.inc \_revisioning_publish_revision()

Make the supplied revision of the node current and publish it. It is the caller's responsibility to provide proper revision. Note that no check is made as to whether the initiating user has permission to publish this revision.

Parameters

$node: Target $node object (loaded with target revision) or nid of target node

$vid: optional vid of revision to make current, if provided $node is not object.

$clear_cache: Whether to clear the cache afterwards or not. Clearing the cache on every node during bulk operations can be time-consuming.

3 calls to _revisioning_publish_revision()
revisioning_publish_confirm_submit in ./revisioning.pages.inc
Submission handler for the publish_confirm form.
revisioning_scheduler_cron in revisioning_scheduler/revisioning_scheduler.module
Implementation of hook_cron If there are any revisions with times that have passed, then publish them and delete them from the database
_revisioning_publish_latest_revision in ./revisioning_api.inc
Find the most recent pending revision, make it current, unless it already is and publish node. Note that no check is made as to whether the initiating user has permission to publish this node.

File

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

Code

function _revisioning_publish_revision(&$node, $vid = NULL, $clear_cache = TRUE) {
  $node_revision = is_object($node) ? $node : node_load($node, $vid);
  $return = module_invoke_all('revisionapi', 'pre publish', $node_revision);
  if (in_array(FALSE, $return)) {
    drupal_goto('node/' . $node_revision->nid . '/revisions/' . $node_revision->vid . '/view');
    die;
  }

  // Update node table, making sure the "published" (ie. status) flag is set
  db_query("UPDATE {node} SET vid=%d, title='%s', status=1 WHERE nid=%d", $node_revision->vid, $node_revision->title, $node_revision->nid);
  if ($clear_cache) {
    cache_clear_all();
  }
  $node_revision->status = 1;
  $node_revision->bypass_nodeapi = TRUE;

  // avoid revisioning_nodeapi() doing stuff
  $node_revision->nodewords = array();

  // avoid nodewords_nodeapi() doing stuff
  // On the first save of a node we should allow pathauto_nodeapi() to create the
  // alias as normal. Otherwise, the alias will not be created if a node is set
  // to be immediately published during creation. See [#1635542].
  if (empty($node->is_new)) {
    $node_revision->pathauto_perform_alias = FALSE;

    // avoid pathauto_nodeapi() doing stuff
  }
  node_invoke_nodeapi($node_revision, 'update');

  // Update the node access table for this node.
  node_access_acquire_grants($node_revision);
  watchdog('content', 'Published rev #%revision of @type %title', array(
    '@type' => $node_revision->type,
    '%title' => $node_revision->title,
    '%revision' => $node_revision->vid,
  ), WATCHDOG_NOTICE, l(t('view'), "node/{$node_revision->nid}/revisions/{$node_revision->vid}/view"));
  module_invoke_all('revisionapi', 'post publish', $node_revision);
}