You are here

function _block_revisions_form_submit in Block Revisions 7

Same name and namespace in other branches
  1. 6 block_revisions.module \_block_revisions_form_submit()
1 string reference to '_block_revisions_form_submit'
block_revisions_form_alter in ./block_revisions.module
Implements hook_form_alter().

File

./block_revisions.module, line 129

Code

function _block_revisions_form_submit($form, &$form_state) {
  global $user;
  $values = $form_state['values'];

  // Get the bid. If this handler is called as the result of an edit,
  // delta will be passed in the form values array. If this is an
  // addition, we need to get the new bid from the database.
  if (isset($values['delta'])) {
    $delta = $values['delta'];
  }
  else {
    $delta = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(
      ':info' => $values['info'],
    ))
      ->fetchField();
  }
  if ($values['revision']) {

    // The "Create a new revision" checkbox was checked, so we need
    // to save a record to the boxes_revisions table.
    block_revisions_create_revision($delta, $values['body']['value'], $values['body']['format'], $values['log']);
  }

  // Update the boxes table for the block that was just saved,
  // adding a timestamp and user information.
  db_update('block_custom')
    ->fields(array(
    'uid' => $user->uid,
    'timestamp' => REQUEST_TIME,
  ))
    ->condition('bid', $delta)
    ->execute();
}