Same name and namespace in other branches
  1. 4.7.x modules/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/node.module, line 1763
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

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) {
      return drupal_get_form('node_revision_revert_confirm', $node);
    }
    else {
      drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');
    }
    drupal_goto('node/' . $nid . '/revisions');
  }
  drupal_access_denied();
}