You are here

function BotchaRecipeNoResubmit::applyRecipe in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 controller/botcha_recipe.controller.inc \BotchaRecipeNoResubmit::applyRecipe()

Overrides BotchaRecipe::applyRecipe

File

controller/botcha_recipe.controller.inc, line 378
Controller layer of the BotchaRecipe objects.

Class

BotchaRecipeNoResubmit

Code

function applyRecipe(&$form, &$form_state) {
  parent::applyRecipe($form, $form_state);

  // Save build id.
  $build_id = $form['#build_id'];

  // !!~ @todo Reduce code duplication.
  // @see BotchaRecipebook.apply()
  $build_id_submit = isset($_POST['form_build_id']) ? $_POST['form_build_id'] : FALSE;

  // Issue the client a new build_id, make sure that the form has it set
  // in the hidden field.
  if ($build_id_submit != $build_id) {
    $form_state['post']['form_build_id'] = $build_id;
  }

  // 6 hours cache life time for forms should be plenty.
  // @todo Provide UI for controlling the botcha_cache_expiration_timeout parameter.
  $expire = variable_get('botcha_cache_expiration_timeout', 21600);
  $data = array();
  $data['#cache_token'] = $this
    ->getToken();

  // We use cache_form table.
  // Sneaky, but why build our own table since we are working side-by-side with form API?
  cache_set('botcha_' . $build_id, $data, 'cache_form', REQUEST_TIME + $expire);
}