You are here

function captcha_admin_settings_submit in CAPTCHA 6

Same name and namespace in other branches
  1. 5.3 captcha.module \captcha_admin_settings_submit()
  2. 6.2 captcha.admin.inc \captcha_admin_settings_submit()
  3. 7 captcha.admin.inc \captcha_admin_settings_submit()

Submission function for captcha_admin_settings form

1 string reference to 'captcha_admin_settings_submit'
captcha_admin_settings in ./captcha.admin.inc
Form builder function for the general CAPTCHA configuration

File

./captcha.admin.inc, line 142

Code

function captcha_admin_settings_submit($form, &$form_state) {
  variable_set('captcha_administration_mode', $form_state['values']['captcha_administration_mode']);
  foreach ($form_state['values']['captcha_types'] as $captcha_point_form_id => $data) {
    if ($data['captcha_type'] == 'none') {
      db_query("UPDATE {captcha_points} SET module = NULL, type = NULL WHERE form_id = '%s'", $captcha_point_form_id);
    }
    else {
      list($module, $type) = explode('/', $data['captcha_type']);
      db_query("UPDATE {captcha_points} SET module = '%s', type = '%s' WHERE form_id = '%s'", $module, $type, $captcha_point_form_id);
    }
  }

  // description stuff
  if (module_exists('locale')) {
    $langs = locale_language_list();
    foreach ($langs as $lang_code => $lang_name) {
      variable_set("captcha_description_{$lang_code}", $form_state['values']["captcha_description_{$lang_code}"]);
    }
  }
  else {
    variable_set('captcha_description', $form_state['values']['captcha_description']);
  }
  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');
}