You are here

function _text_captcha_word_pool_validate in CAPTCHA Pack 7

Same name and namespace in other branches
  1. 8 text_captcha/text_captcha.module \_text_captcha_word_pool_validate()
  2. 5 text_captcha/text_captcha.inc \_text_captcha_word_pool_validate()
  3. 6 text_captcha/text_captcha.inc \_text_captcha_word_pool_validate()

Helper function for validating the word pool Locale dependent

3 calls to _text_captcha_word_pool_validate()
lost_character_captcha_settings_form_validate in text_captcha/lost_character_captcha/lost_character_captcha.admin.inc
Validation function for the settings form
phrase_captcha_settings_form_validate in text_captcha/phrase_captcha/phrase_captcha.admin.inc
Validate function of the administration form
word_list_captcha_settings_form_validate in text_captcha/word_list_captcha/word_list_captcha.admin.inc
Validation function for the settings form

File

text_captcha/text_captcha.inc, line 120

Code

function _text_captcha_word_pool_validate($name_base, $form_values, $minimum_count, $minimum_length = NULL, $too_short_message = '') {
  if (module_exists('locale')) {
    $langs = locale_language_list();
    foreach ($langs as $lang_code => $lang_name) {
      $words = _text_captcha_whitespace_explode($form_values["{$name_base}_{$lang_code}"]);
      if (count($words) < $minimum_count) {
        form_set_error("{$name_base}_{$lang_code}", t('You should provide at least @num words', array(
          '@num' => $minimum_count,
        )));
      }

      // Check the minimum word length (if needed)
      if ($minimum_length) {
        _text_captcha_word_pool_validate_word_length("{$name_base}_{$lang_code}", $words, $minimum_length, $too_short_message);
      }
    }
  }
  else {
    $words = _text_captcha_whitespace_explode($form_values[$name_base]);
    if (count($words) < $minimum_count) {
      form_set_error($name_base, t('You should provide at least @num words', array(
        '@num' => $minimum_count,
      )));
    }
    if ($minimum_length) {
      _text_captcha_word_pool_validate_word_length($name_base, $words, $minimum_length, $too_short_message);
    }
  }
}