function tfa_admin_settings_submit in Two-factor Authentication (TFA) 7.2
Admin form submission handler.
File
- ./
tfa.admin.inc, line 196 - TFA Administration and settings functions.
Code
function tfa_admin_settings_submit($form, &$form_state) {
drupal_set_message(t('Configuration saved'));
$values = $form_state['values'];
// Set enabled.
if (!empty($values['tfa_enabled'])) {
variable_set('tfa_enabled', $values['tfa_enabled']);
}
else {
variable_del('tfa_enabled');
return;
}
// Set main validation plugins.
variable_set('tfa_validate_plugin', $values['tfa_validate']);
// Set fallback plugins.
$fallback = array();
if (!empty($values['tfa_fallback'])) {
foreach ($values['tfa_fallback'] as $key => $data) {
if ($values['tfa_validate'] !== $key && $data['enable']) {
$fallback[$data['weight']] = $key;
}
}
}
// Always include the default validation plugin in case the context plugins
// are altered. TFA will skip it if it's the same as validation at runtime.
$fallback[-999] = $values['tfa_validate'];
ksort($fallback);
variable_set('tfa_fallback_plugins', $fallback);
// Set login plugins.
$login = array();
if (!empty($values['tfa_login'])) {
foreach ($values['tfa_login'] as $key => $enabled) {
if ($enabled) {
$login[] = $key;
}
}
}
variable_set('tfa_login_plugins', $login);
}