You are here

function ajax_captcha_process in Ajax 6

Captcha functionality This depends on the provided captcha patches

Parameters

$form Assoc:

$form_state Assoc:

$data Assoc:

Return value

Bool

2 calls to ajax_captcha_process()
ajax_captcha_ajax_validate_fail in plugins/captcha/ajax_captcha.module
validation fail hook
ajax_captcha_ajax_validate_pass in plugins/captcha/ajax_captcha.module
validation fail hook

File

plugins/captcha/ajax_captcha.module, line 50

Code

function ajax_captcha_process(&$form, &$form_state, &$data) {

  //print_r($data);
  if (array_key_exists('captcha_token', $form_state['values']) && array_key_exists('captcha_type', $form_state['values']) && array_key_exists('captcha_query', $form_state['values'])) {

    //$data['debug'] .= 'B';

    // Conditional show
    if (_captcha_required_for_user($form_state['values']['captcha_sid'], $form_id) == NULL) {
      $data['updaters'][] = array(
        'type' => 'hide',
        'selector' => 'fieldset.captcha',
        'value' => NULL,
      );

      //$data['debug'] .= 'C';
    }

    //$data['debug'] .= 'D';

    // MATH
    if ($form_state['values']['captcha_type'] === 'math') {
      $selector = "#edit-captcha-response-wrapper .field-prefix";
      $type = 'html_in';

      //$data['debug'] .= 'E';
    }
    elseif ($form_state['values']['captcha_type'] === 'text') {
      $selector = "#edit-captcha-response-wrapper label[for='edit-captcha-response']";
      $type = 'html_in';

      //$data['debug'] .= 'F';
    }
    elseif ($form_state['values']['captcha_type'] === 'image') {
      $selector = ".captcha img";
      $type = 'html_out';

      //$data['debug'] .= 'G';
    }
    $data['updaters'][] = array(
      'type' => 'field',
      'selector' => '#edit-captcha-token',
      'value' => $form_state['values']['captcha_token'],
    );
    $data['updaters'][] = array(
      'type' => $type,
      'selector' => $selector,
      'value' => $form_state['values']['captcha_query'],
    );
    $data['updaters'][] = array(
      'type' => 'field',
      'selector' => '#edit-captcha-response',
      'value' => '',
    );
    theme_captcha($form);
  }
  return TRUE;
}