public function SecuresiteSettingsForm::submitForm in Secure Site 8
Configure access denied page and manage stored guest password.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ SecuresiteSettingsForm.php, line 154 - Contains \Drupal\securesite\Form\SecuresiteSettingsForm.
Class
Namespace
Drupal\securesite\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state['values'];
$config_securesite = $this
->config('securesite.settings');
$config_site = $this
->config('system.site');
$config_securesite
->set('securesite_enabled', $values['securesite_enabled'])
->set('securesite_type', $values['securesite_type'])
->set('securesite_digest_script', $values['securesite_digest_script'])
->set('securesite_password_script', $values['securesite_password_script'])
->set('securesite_realm', $values['securesite_realm'])
->set('securesite_guest_name', $values['securesite_guest_name'])
->set('securesite_guest_pass', $values['securesite_guest_pass'])
->set('securesite_login_form', $values['securesite_login_form'])
->set('securesite_reset_form', $values['securesite_reset_form'])
->save();
if ($values['securesite_enabled'] != SECURESITE_403 || isset($values['op']) && $values['op'] == t('Reset to defaults')) {
$config_site
->set('page.403', $config_securesite
->get('securesite_403'))
->save();
$config_securesite
->clear('securesite_403')
->save();
}
else {
$config_securesite
->set('securesite_403', $config_site
->get('page.403'))
->save();
$config_site
->set('page.403', $config_site
->get('securesite_403'))
->save();
}
$script = $config_securesite
->get('securesite_password_script');
$realm = $config_securesite
->get('securesite_realm');
$site_path = DrupalKernel::findSitePath(\Drupal::request());
if (in_array(SECURESITE_DIGEST, $config_securesite
->get('securesite_type'))) {
// If digest authentication was enabled, we may need to do some clean-up.
$securesite_guest_name = $config_securesite
->get('securesite_guest_name');
if (isset($values['op']) && $values['op'] == t('Reset to defaults') || !in_array(SECURESITE_DIGEST, $values['securesite_type']) || $realm != $values['securesite_realm']) {
// Delete all stored passwords.
exec("{$script} realm=" . escapeshellarg($realm) . ' op=delete site_path=' . $site_path);
}
elseif ($values['securesite_guest_name'] != $securesite_guest_name) {
// Guest user name has changed. Delete old guest user password.
exec("{$script} username=" . escapeshellarg($securesite_guest_name) . ' realm=' . escapeshellarg($realm) . ' op=delete site_path=' . $site_path);
}
}
if (in_array(SECURESITE_DIGEST, $values['securesite_type']) && (!isset($values['op']) || $values['op'] != t('Reset to defaults'))) {
// If digest authentication is enabled, update guest user password.
$args = array(
'username=' . escapeshellarg($values['securesite_guest_name']),
'pass=' . escapeshellarg($values['securesite_guest_pass']),
'realm=' . escapeshellarg($realm),
'op=create',
'site_path=' . $site_path,
);
exec($script . ' ' . implode(' ', $args));
}
parent::submitForm($form, $form_state);
}