public function AutologoutSettingsForm::submitForm in Automated Logout 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ AutologoutSettingsForm.php, line 405
Class
- AutologoutSettingsForm
- Provides settings for autologout module.
Namespace
Drupal\autologout\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$autologout_settings = $this
->config('autologout.settings');
$old_no_individual_logout_threshold = $autologout_settings
->get('no_individual_logout_threshold');
$new_no_individual_logout_threshold = (bool) $values['no_individual_logout_threshold'];
$autologout_settings
->set('timeout', $values['timeout'])
->set('max_timeout', $values['max_timeout'])
->set('padding', $values['padding'])
->set('no_individual_logout_threshold', $values['no_individual_logout_threshold'])
->set('logout_regardless_of_activity', $values['logout_regardless_of_activity'])
->set('role_logout', $values['role_logout'])
->set('role_logout_max', $values['role_logout_max'])
->set('redirect_url', $values['redirect_url'])
->set('no_dialog', $values['no_dialog'])
->set('dialog_title', $values['dialog_title'])
->set('message', $values['message'])
->set('inactivity_message', $values['inactivity_message'])
->set('inactivity_message_type', $values['inactivity_message_type'])
->set('disable_buttons', $values['disable_buttons'])
->set('yes_button', $values['yes_button'])
->set('no_button', $values['no_button'])
->set('enforce_admin', $values['enforce_admin'])
->set('whitelisted_ip_addresses', $values['whitelisted_ip_addresses'])
->set('use_alt_logout_method', $values['use_alt_logout_method'])
->set('use_watchdog', $values['use_watchdog'])
->save();
foreach ($values['table'] as $user) {
$this
->configFactory()
->getEditable('autologout.role.' . $user['role'])
->set('enabled', $user['enabled'])
->set('timeout', $user['timeout'])
->set('url', $user['url'])
->save();
}
if (isset($values['jstimer_format'])) {
$autologout_settings
->set('jstimer_format', $values['jstimer_format'])
->save();
}
// If individual logout threshold setting is no longer enabled,
// clear existing individual timeouts from users.
if ($old_no_individual_logout_threshold === FALSE && $new_no_individual_logout_threshold === TRUE) {
$users_timeout = $this->userData
->get('autologout', NULL, 'timeout');
foreach ($users_timeout as $uid => $current_timeout_value) {
if ($current_timeout_value !== NULL) {
$this->userData
->set('autologout', $uid, 'timeout', NULL);
}
}
}
parent::submitForm($form, $form_state);
}