function captcha_after_get_forms_settings in CAPTCHA After 7
Same name and namespace in other branches
- 6 captcha_after.module \captcha_after_get_forms_settings()
Helper function for returning captcha_after forms configuration values.
2 calls to captcha_after_get_forms_settings()
- captcha_after_form_alter in ./
captcha_after.module - Implementation of hook_form_alter().
- captcha_after_show_captcha in ./
captcha_after.module - Tests current form on captcha after threashold settings.
File
- ./
captcha_after.module, line 122 - Show CAPTCHA protection on selected forms after specified number of unsuccessful form submit attempts has been made.
Code
function captcha_after_get_forms_settings($form_id) {
$form_settings = captcha_after_db_get_form($form_id);
$settings['enable'] = FALSE;
// If we do not have captcha_after settings for this form or captcha_after is
// disabled for this form there is nothign to do.
if (!$form_settings || !$form_settings['enable']) {
return $settings;
}
$settings['enable'] = $form_settings['enable'];
// Load global settings for all forms.
$settings['submit_threshold'] = variable_get('captcha_after_submit_threshold', 3);
$settings['flooding_threshold'] = variable_get('captcha_after_flooding_threshold', 3);
$settings['global_flooding_threshold'] = variable_get('captcha_after_global_flooding_threshold', 1000);
// Overide global settings where needed.
if ($form_settings = captcha_after_db_get_form($form_id)) {
foreach ($settings as $key => $value) {
if (isset($form_settings['options'][$key]) && $form_settings['options'][$key] != '') {
$settings[$key] = $form_settings['options'][$key];
}
}
}
return $settings;
}