You are here

function eck_revision_revision_revert_confirm_submit in ECK Revision 7

Form submission handler for eck_revision_revision_revert_confirm().

File

./eck_revision.pages.inc, line 128
Page callbacks for revisions management for entities.

Code

function eck_revision_revision_revert_confirm_submit($form, &$form_state) {
  $revision = $form['#revision'];
  $revision_id = $revision->revision_id;
  $title = entity_label($form['#entity_type'], $revision);
  $revision->is_new = FALSE;
  $revision->is_new_revision = TRUE;
  $revision->default_revision = TRUE;
  $revision->revision_log = t('Copy of the revision %num.', array(
    '%num' => $revision->revision_id,
  ));
  $revision
    ->save();
  watchdog('eck_revision', '@type: reverted %title revision %num.', array(
    '@type' => $revision->type,
    '%title' => $title,
    '%num' => $revision_id,
  ));
  drupal_set_message(t('@type %title has been reverted back to the revision from %num.', array(
    '@type' => $revision->type,
    '%title' => $title,
    '%num' => $revision_id,
  )));
  $form_state['redirect'] = $form['#path'] . '/revisions';
}