From 833fdebff58b21b7a11d4af9b63bbc5c15ad6cbc Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Thu, 21 Mar 2024 14:42:43 +0000 Subject: [PATCH] settings/calendar: check for start and end time and allow the end time to be set to 24:00, fixes #3868 Closes #3868 Merge request studip/studip!2721 --- app/controllers/settings/calendar.php | 17 +++++++++++++++-- app/views/settings/calendar.php | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/settings/calendar.php b/app/controllers/settings/calendar.php index b2f4f1c55af..50c556be538 100644 --- a/app/controllers/settings/calendar.php +++ b/app/controllers/settings/calendar.php @@ -56,10 +56,23 @@ class Settings_CalendarController extends Settings_SettingsController { $this->check_ticket(); + $start = Request::option('cal_start'); + $end = Request::option('cal_end'); + if ($start >= $end) { + PageLayout::postError(_('Die Startuhrzeit muss vor der Enduhrzeit liegen.')); + $calendar_user_control_data = (array) UserConfig::get($GLOBALS['user']->id)->getValue('CALENDAR_SETTINGS'); + foreach ($calendar_user_control_data as $key => $value) { + $this->$key = $value; + } + $this->start = $start; + $this->end = $end; + return; + } + $this->config->store('CALENDAR_SETTINGS', [ 'view' => Request::option('cal_view'), - 'start' => Request::option('cal_start'), - 'end' => Request::option('cal_end'), + 'start' => $start, + 'end' => $end, 'step_day' => Request::option('cal_step_day'), 'step_week' => Request::option('cal_step_week'), 'type_week' => Request::option('cal_type_week'), diff --git a/app/views/settings/calendar.php b/app/views/settings/calendar.php index 889120ad72a..aecc23463ee 100644 --- a/app/views/settings/calendar.php +++ b/app/views/settings/calendar.php @@ -78,7 +78,7 @@ $cal_step_weeks = [ <label> <?= _('Enduhrzeit') ?> <select name="cal_end" aria-label="<?= _('Endzeit der Tages- und Wochenansicht') ?>" class="size-s"> - <? for ($i = 0; $i < 24; $i += 1): ?> + <? for ($i = 1; $i < 25; $i += 1): ?> <option value="<?= $i ?>" <? if ($end == $i) echo 'selected'; ?>> <?= sprintf(_('%02u:00 Uhr'), $i) ?> </option> -- GitLab