function captcha_admin_settings_submit in CAPTCHA 6.2
Same name and namespace in other branches
- 5.3 captcha.module \captcha_admin_settings_submit()
- 6 captcha.admin.inc \captcha_admin_settings_submit()
- 7 captcha.admin.inc \captcha_admin_settings_submit()
Submission function for captcha_admin_settings form.
File
- ./
captcha.admin.inc, line 275 - Functionality and helper functions for CAPTCHA administration.
Code
function captcha_admin_settings_submit($form, &$form_state) {
variable_set('captcha_administration_mode', $form_state['values']['captcha_administration_mode']);
variable_set('captcha_allow_on_admin_pages', $form_state['values']['captcha_allow_on_admin_pages']);
variable_set('captcha_default_challenge', $form_state['values']['captcha_default_challenge']);
// Process CAPTCHA points
if (isset($form_state['values']['captcha_form_id_overview']['captcha_captcha_points'])) {
// Load existing data.
$captcha_points = captcha_get_captcha_points();
foreach ($form_state['values']['captcha_form_id_overview']['captcha_captcha_points'] as $captcha_point_form_id => $data) {
// If this is an in-code captcha point and its settings are unchanged,
// don't save to the database.
if (module_exists('ctools') && isset($captcha_points[$captcha_point_form_id])) {
// Parse module and captcha_type from submitted values.
$captcha_type = $data['captcha_type'];
if (is_string($captcha_type) && substr_count($captcha_type, '/') == 1) {
list($module, $subtype) = explode('/', $data['captcha_type']);
}
else {
$module = NULL;
$subtype = $captcha_type === 'none' ? NULL : $captcha_type;
}
$point = $captcha_points[$captcha_point_form_id];
if ($point->export_type & EXPORT_IN_CODE && !($point->export_type & EXPORT_IN_DATABASE) && $point->module == $module && $point->captcha_type == $subtype) {
continue;
}
}
captcha_set_form_id_setting($captcha_point_form_id, $data['captcha_type']);
}
}
// Add new CAPTCHA point?
$captcha_point_form_id = $form_state['values']['captcha_form_id_overview']['captcha_new_captcha_point']['form_id'];
if (!empty($captcha_point_form_id)) {
$captcha_type = $form_state['values']['captcha_form_id_overview']['captcha_new_captcha_point']['captcha_type'];
captcha_set_form_id_setting($captcha_point_form_id, $captcha_type);
drupal_set_message(t('Added CAPTCHA point.'), 'status');
}
// CAPTCHA description stuff.
variable_set('captcha_add_captcha_description', $form_state['values']['captcha_add_captcha_description']);
// Save (or reset) the CAPTCHA descriptions.
if (module_exists('locale')) {
$langs = locale_language_list();
foreach ($langs as $lang_code => $lang_name) {
$description = $form_state['values']["captcha_description_{$lang_code}"];
if ($description) {
variable_set("captcha_description_{$lang_code}", $description);
}
else {
variable_del("captcha_description_{$lang_code}");
drupal_set_message(t('Reset of CAPTCHA description for language %language.', array(
'%language' => $lang_name,
)), 'status');
}
}
}
else {
$description = $form_state['values']['captcha_description'];
if ($description) {
variable_set('captcha_description', $description);
}
else {
variable_del('captcha_description');
drupal_set_message(t('Reset of CAPTCHA description.'), 'status');
}
}
variable_set('captcha_default_validation', $form_state['values']['captcha_default_validation']);
variable_set('captcha_persistence', $form_state['values']['captcha_persistence']);
variable_set('captcha_log_wrong_responses', $form_state['values']['captcha_log_wrong_responses']);
drupal_set_message(t('The CAPTCHA settings were saved.'), 'status');
}