node_revision_revert

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 1333

<?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();
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.