You are here

function captcha_after_show_captcha in CAPTCHA After 6

Same name and namespace in other branches
  1. 7 captcha_after.module \captcha_after_show_captcha()

Tests current form on captcha after threashold settings.

Parameters

string $form_id: Form id.

Return value

boolean If some of the threasholds are reached returns TRUE (captcha should be shown). If not returns FALSE.

2 calls to captcha_after_show_captcha()
captcha_after_form_after_build in ./captcha_after.module
After build state of form. Decide should we skip captcha element validation.
captcha_after_form_pre_render in ./captcha_after.module
Form is in pre rendered state.

File

./captcha_after.module, line 185
Show CAPTCHA protection on selected forms after specified number of unsuccessful form submit attempts has been made.

Code

function captcha_after_show_captcha($form_id) {

  // Get captcha_after settings for this form.
  $ca_settings = captcha_after_get_forms_settings($form_id);

  // Now we will test all captcha_after threshold settings.
  // If some settings is empty or 0 we will not take it into consideration.
  if (!empty($ca_settings['flooding_threshold']) && !flood_is_allowed($form_id, $ca_settings['flooding_threshold'])) {
    return TRUE;
  }
  if (!empty($ca_settings['submit_threshold']) && !flood_is_allowed('captcha_after_' . $form_id, $ca_settings['submit_threshold'])) {
    return TRUE;
  }
  if (!empty($ca_settings['global_flooding_threshold']) && !captcha_after_global_flood_is_allowed($form_id, $ca_settings['global_flooding_threshold'])) {
    return TRUE;
  }

  // All captcha_after tests are passed so we do not need to show captcha.
  return FALSE;
}