You are here

function BotchaRecipebookAbstract::apply in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 controller/botcha_recipebook.controller.inc \BotchaRecipebookAbstract::apply()

File

controller/botcha_recipebook.controller.inc, line 372
Controller layer of the BotchaRecipebook objects.

Class

BotchaRecipebookAbstract
@file Controller layer of the BotchaRecipebook objects.

Code

function apply(&$form, &$form_state) {
  $form_state['no_cache'] = TRUE;
  if (!empty($_POST['form_build_id'])) {
    $build_id = $_POST['form_build_id'];
    $method = 'build_id_submit';
  }
  else {
    $build_id = $form['#build_id'];
    $method = 'build_id';
  }
  $this
    ->applyForBuildId($form, $form_state, $method, $build_id);

  // User_login forms open session in validate hooks instead of submit
  // we should be the first to validate - add our hook to the beginning
  if (is_array($form['#validate'])) {

    // Workaround since array_unshift'ing by reference was deprecated.
    // @see http://www.php.net/manual/ru/function.array-unshift.php#40270
    array_unshift($form['#validate'], '');
    $form['#validate'][0] = '_botcha_form_validate';
  }
  else {
    $form['#validate'] = array(
      '_botcha_form_validate',
    );
  }
  $form_state['#botcha'] = $this->id;

  // Logging.
  $csss = $this
    ->getCsss();
  $jss = $this
    ->getJss();
  if (BOTCHA_LOGLEVEL >= 4) {
    watchdog(BOTCHA_LOG, '%form_id form prepared by BOTCHA: added recipes - !botchas!more', array(
      '%form_id' => $form['form_id']['#value'],
      '!botchas' => join(', ', $this->recipes),
      '!more' => '' . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'POST=<pre>' . print_r(_botcha_filter_value($_POST), 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'GET=<pre>' . print_r(_botcha_filter_value($_GET), 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'SERVER=<pre>' . print_r($_SERVER, 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 ? '<br /><br />' . 'form=<pre>' . print_r(_botcha_filter_form_log($form), 1) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 && count($jss) ? '<br /><br />' . 'JS=<pre>' . join("\n", $jss) . '</pre>' : '') . (BOTCHA_LOGLEVEL >= 5 && count($csss) ? '<br /><br />' . 'CSS=<pre>' . join("\n", $csss) . '</pre>' : ''),
    ), WATCHDOG_NOTICE);
  }
}