node_revision_revert

  1. drupal
    1. 4.7
    2. 5 node.module
Versions
4.7 – 5 node_revision_revert($nid, $revision)

Revert to the revision with the specified revision number. A node and nodeapi "update" event is triggered (via the node_save() call) when a revision is reverted.

Code

modules/node.module, line 1334

<?php
function node_revision_revert($nid, $revision) {
  global $user;

  $node = node_load($nid, $revision);
  if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
    if ($node->vid) {
      $form = array();
      $form['nid'] = array(
        '#type' => 'value',
        '#value' => $node->nid,
      );
      $form['vid'] = array(
        '#type' => 'value',
        '#value' => $node->vid,
      );
      return confirm_form('node_revision_revert_confirm', $form,  
                     t('Are you sure you want to revert %title to the revision from %revision-date?', array('%title' => theme('placeholder', $node->title), '%revision-date' => theme('placeholder', format_date($node->revision_timestamp)))), 
                     "node/$nid/revisions", ' ', t('Revert'), t('Cancel'));
    }
    else {
      drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');
    }
    drupal_goto('node/' . $nid . '/revisions');
  }
  drupal_access_denied();
}
?>