You are here

function block_revisions_revert_confirm_submit in Block Revisions 6

Same name and namespace in other branches
  1. 7 block_revisions.admin.inc \block_revisions_revert_confirm_submit()

File

./block_revisions.admin.inc, line 17
Admin functions and page callbacks for the Block Revisions module.

Code

function block_revisions_revert_confirm_submit($form, &$form_state) {
  global $user;
  $revision = $form['#block_revision'];
  $delta = $revision->bid;
  $vid = $revision->vid;
  $message = t('Copy of the revision from !date.', array(
    '!date' => format_date($revision->timestamp),
  ));
  db_query("UPDATE {boxes} SET body = '%s', format = %d, uid = %d, timestamp = %d WHERE bid = %d", $revision->body, $revision->format, $user->uid, time(), $delta);
  block_revisions_create_revision($delta, $revision->body, $revision->format, $message);
  if (db_result(db_query('SELECT COUNT(vid) FROM {boxes_revisions} WHERE bid = %d', $delta)) > 1) {
    $form_state['redirect'] = "admin/build/block/configure/block/{$delta}/revisions";
  }
  else {
    $form_state['redirect'] = "admin/build/block/configure/block/{$delta}";
  }
}