function node_revision_revert_confirm_submit

Form submission handler for node_revision_revert_confirm().

File

drupal/core/modules/node/node.pages.inc, line 329
Callbacks for adding, editing, and deleting content and managing revisions.

Code

function node_revision_revert_confirm_submit($form, &$form_state) {
  $node_revision = $form['#node_revision'];
  $node_revision
    ->setNewRevision();

  // Make this the new default revision for the node.
  $node_revision
    ->isDefaultRevision(TRUE);

  // The revision timestamp will be updated when the revision is saved. Keep the
  // original one for the confirmation message.
  $original_revision_timestamp = $node_revision->revision_timestamp;
  $node_revision->log = t('Copy of the revision from %date.', array(
    '%date' => format_date($original_revision_timestamp),
  ));
  $node_revision
    ->save();
  watchdog('content', '@type: reverted %title revision %revision.', array(
    '@type' => $node_revision->type,
    '%title' => $node_revision
      ->label(),
    '%revision' => $node_revision->vid,
  ));
  drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array(
    '@type' => node_get_type_label($node_revision),
    '%title' => $node_revision
      ->label(),
    '%revision-date' => format_date($original_revision_timestamp),
  )));
  $form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
}