diff options
| -rw-r--r-- | app/controllers/nobody_settings.php | 48 | ||||
| -rw-r--r-- | templates/header.php | 19 | ||||
| -rw-r--r-- | templates/login/_header_contrast.php | 18 | ||||
| -rw-r--r-- | templates/login/_header_languages.php | 3 |
4 files changed, 69 insertions, 19 deletions
diff --git a/app/controllers/nobody_settings.php b/app/controllers/nobody_settings.php new file mode 100644 index 0000000..993f218 --- /dev/null +++ b/app/controllers/nobody_settings.php @@ -0,0 +1,48 @@ +<?php + +use Trails\Controller; + +/** + * nobody_settings.php - contrast and language settings for nobody + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * @author Michaela Brückner <brueckner@data-quest.de> + * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 + * @category Stud.IP + */ + +class NobodySettingsController extends StudipController +{ + protected $with_session = true; + + public function store_settings_action() + { + + $this->page = Request::get('page'); + + if (Request::submitted('user_config_submitted')) { + CSRFProtection::verifyUnsafeRequest(); + + if (Request::submitted('unset_contrast')) { + $_SESSION['contrast'] = 0; + } + if (Request::submitted('set_contrast')) { + $_SESSION['contrast'] = 1; + } + + foreach (array_keys($GLOBALS['INSTALLED_LANGUAGES']) as $language_key) { + if (Request::get('set_language') === $language_key) { + $_SESSION['forced_language'] = $language_key; + $_SESSION['_language'] = $language_key; + } + } + } + + $this->redirect($this->page); //we're too late to remove the high contrast mode, so we reload the page + } + +} diff --git a/templates/header.php b/templates/header.php index b4df4c4..c11d973 100644 --- a/templates/header.php +++ b/templates/header.php @@ -184,24 +184,7 @@ if ($navigation) { ]) ?> </li> <? else: ?> - <li> - <form method="post" action="<?= URLHelper::getLink(Request::url(), ['cancel_login' => null]) ?>"> - <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException){}?> - <input type="hidden" name="user_config_submitted" value="1"> - <div id="contrast"> - <? if (!empty($_SESSION['contrast'])): ?> - <?= Icon::create('accessibility', Icon::ROLE_INFO_ALT)->asSvg(24) ?> - <button class="as-link" name="unset_contrast"><?= _('Normalen Kontrast aktivieren') ?></button> - <?= tooltipIcon(_('Aktiviert standardmäßige, nicht barrierefreie Kontraste.'), false, false, true); ?> - <? else: ?> - <?= Icon::create('accessibility', Icon::ROLE_INFO_ALT)->asSvg(24) ?> - <button class="as-link" name="set_contrast"><?= _('Hohen Kontrast aktivieren') ?></button> - <?= tooltipIcon(_('Aktiviert einen hohen Kontrast gemäß WCAG 2.1. Diese Einstellung wird nach dem Login übernommen. - Sie können sie in Ihren persönlichen Einstellungen ändern.'), false, false, true); ?> - <? endif ?> - </div> - </form> - </li> + <li><?= $this->render_partial('login/_header_contrast') ?></li> <li><?= $this->render_partial('login/_header_languages') ?></li> <? endif; ?> diff --git a/templates/login/_header_contrast.php b/templates/login/_header_contrast.php new file mode 100644 index 0000000..d98db07 --- /dev/null +++ b/templates/login/_header_contrast.php @@ -0,0 +1,18 @@ +<form method="post" action="<?= URLHelper::getLink('dispatch.php/nobody_settings/store_settings') ?>"> + <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException){}?> + <input type="hidden" name="user_config_submitted" value="1"> + <input type="hidden" name="page" value="<?= Request::url() ?>"> + <div id="contrast"> + <? if (!empty($_SESSION['contrast'])): ?> + <?= Icon::create('accessibility', Icon::ROLE_INFO_ALT)->asSvg(24) ?> + <button class="as-link" name="unset_contrast"><?= _('Normalen Kontrast aktivieren') ?></button> + <?= tooltipIcon(_('Aktiviert standardmäßige, nicht barrierefreie Kontraste.'), false, false, true); ?> + <? else: ?> + <?= Icon::create('accessibility', Icon::ROLE_INFO_ALT)->asSvg(24) ?> + <button class="as-link" name="set_contrast"><?= _('Hohen Kontrast aktivieren') ?></button> + <?= tooltipIcon(_('Aktiviert einen hohen Kontrast gemäß WCAG 2.1. Diese Einstellung wird nach dem Login übernommen. + Sie können sie in Ihren persönlichen Einstellungen ändern.'), false, false, true); ?> + <? endif ?> + </div> + +</form> diff --git a/templates/login/_header_languages.php b/templates/login/_header_languages.php index 6504cc9..435ab38 100644 --- a/templates/login/_header_languages.php +++ b/templates/login/_header_languages.php @@ -1,6 +1,7 @@ -<form id="language-selector" method="POST" action="<?= URLHelper::getLink(Request::url(), ['cancel_login' => null]) ?>"> +<form id="language-selector" method="POST" action="<?= URLHelper::getLink('dispatch.php/nobody_settings/store_settings') ?>"> <? try {echo CSRFProtection::tokenTag();} catch (SessionRequiredException) {}?> <input type="hidden" name="user_config_submitted" value="1"> + <input type="hidden" name="page" value="<?= htmlReady(Request::url()) ?>"> <select id="languages" name="set_language" class="select2" onchange="this.form.submit()"> <? foreach ($GLOBALS['INSTALLED_LANGUAGES'] as $temp_language_key => $temp_language): ?> <option value="<?= htmlReady($temp_language_key) ?>" <?= array_key_exists('_language', $_SESSION) && $_SESSION['_language'] === $temp_language_key ? 'selected' : '' ?> |
