You are here

function recaptcha_v3_admin_settings_submit in reCAPTCHA v3 7

Submit function for recaptcha_v3_admin_settings().

See also

recaptcha_v3_admin_settings()

File

./recaptcha_v3.admin.inc, line 200
Provides the Google No CAPTCHA administration settings.

Code

function recaptcha_v3_admin_settings_submit($form, &$form_state) {
  variable_set('recaptcha_v3_site_key', $form_state['values']['recaptcha_v3_site_key']);
  variable_set('recaptcha_v3_secret_key', $form_state['values']['recaptcha_v3_secret_key']);
  variable_set('recaptcha_v3_verify_hostname', $form_state['values']['recaptcha_v3_verify_hostname']);
  variable_set('recaptcha_v3_captcha_default_challenge', $form_state['values']['actions_settings']['recaptcha_v3_captcha_default_challenge']);
  variable_set('recaptcha_v3_error_message', $form_state['values']['recaptcha_v3_error_message']);
  $actions = _recaptcha_v3_get_all_actions();
  if (!empty($form_state['values']['actions_settings']['overview'])) {
    $count = 0;
    $form_actions = $form_state['values']['actions_settings']['overview'];
    foreach ($form_actions as $id => $form_action) {
      if (isset($actions[$id]) && $actions[$id] != $form_action) {
        $count += db_update('recaptcha_v3_actions')
          ->fields($form_action)
          ->condition('id', $id)
          ->execute();
      }
    }
    drupal_set_message(format_plural($count, '1 action has been updated.', '@count actions has been updated.'));
  }
  $new_action = $form_state['values']['actions_settings']['new'];
  if (!empty($new_action['action'])) {
    $res = drupal_write_record('recaptcha_v3_actions', $new_action);
    if ($res) {
      drupal_set_message(t('New action has been created.'));
    }
    else {
      drupal_set_message(t('An error happened during creation of thr new action.'));
    }
  }
}