Same name and namespace in other branches
  1. 5.x modules/node/node.module \node_revision_revert()

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.

File

modules/node.module, line 1333
The core that allows content to be submitted to the site.

Code

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();
}