You are here

public function BotchaRecipeNoResubmit::apply in BOTCHA Spam Prevention 7.3

Same name and namespace in other branches
  1. 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeNoResubmit::apply()

Overrides BotchaRecipe::apply

File

controller/recipe/botcha.recipe.controller.inc, line 428
Controller layer of the BotchaRecipe objects.

Class

BotchaRecipeNoResubmit

Code

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

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

  // @todo Reduce code duplication (determining which build_id to use).
  // @see BotchaRecipebook.apply()
  // @see?
  $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.
  // @see?
  $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?
  // @todo Abstract it.

  //cache_set('botcha_' . $build_id, $data, 'cache_form', $_SERVER['REQUEST_TIME'] + $expire);
  cache_set('botcha_' . $build_id, $data, 'cache_form', REQUEST_TIME + $expire);
}