function _botcha_form_validate in BOTCHA Spam Prevention 6.2
Same name and namespace in other branches
- 6 botcha.botcha.inc \_botcha_form_validate()
- 7 botcha.module \_botcha_form_validate()
- 7.2 botcha.module \_botcha_form_validate()
Custom form validation - jump to __botcha_form_validate(). FIXME: Is there a standard way to put #validate handlers in a separate file?
1 string reference to '_botcha_form_validate'
File
- ./botcha.module, line 328 
Code
function _botcha_form_validate($form, &$form_state) {
  // FIXME: where does this empty value come from ? happens with comments
  unset($form_state['values']['']);
  // Get an instance of BOTCHA special form handler.
  $botcha_form = Botcha::getForm($form['form_id']['#value'], FALSE);
  // Check if it is allowed to protect.
  if ($botcha_form
    ->isEnabled()) {
    // Fetch a recipe book and handle spam protection.
    $recipebook = $botcha_form
      ->getRecipebook();
    if ($recipebook
      ->isApplicable($form, $form_state)) {
      if ($recipebook
        ->isSpam($form, $form_state)) {
        $recipebook
          ->handle('spam', $form, $form_state);
      }
      else {
        $recipebook
          ->handle('success', $form, $form_state);
      }
    }
  }
}