From 991f2829e266bfcaf51fbf465e3ed82887770bc6 Mon Sep 17 00:00:00 2001 From: Moritz Strohm Date: Fri, 30 Jan 2026 09:42:10 +0000 Subject: added a valid range for the navigation in the day view of the schedule, fixes #6104 Closes #6104 Merge request studip/studip!4700 --- lib/classes/calendar/Helper.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/classes/calendar/Helper.php b/lib/classes/calendar/Helper.php index 5e3c181..b20cc32 100644 --- a/lib/classes/calendar/Helper.php +++ b/lib/classes/calendar/Helper.php @@ -174,6 +174,23 @@ class Helper ] ]; + //Calculate the valid range for the schedule. This should be the current week. + //All dates are converted to fit into it. + //Together with the "hiddenDays" property, only those days that shall be visible + //can be browsed in the day view. + $valid_start = new \DateTime(); + if ($valid_start->format('N') !== '1') { + //Make sure to start on monday: + $dow = (int) $valid_start->format('N'); + $dow--; + $interval = new \DateInterval(sprintf('P%uD', $dow)); + $valid_start = $valid_start->sub($interval); + } + $valid_start->setTime(0, 0, 0); + $valid_end = clone $valid_start; + $valid_end = $valid_end->add(new \DateInterval('P1W')); + //The end date is exclusive, so it must lie on the next day. + return new \Studip\Fullcalendar( _('Stundenplan'), [ @@ -196,8 +213,12 @@ class Helper 'minute' => '2-digit', 'omitZeroMinute' => false ], - 'weekends' => true, - 'weekNumbers' => false, + 'weekends' => true, + 'weekNumbers' => false, + 'validRange' => [ + 'start' => $valid_start->format('Y-m-d'), + 'end' => $valid_end->format('Y-m-d') + ], 'hiddenDays' => $fullcalendar_hidden_days, 'timeGridEventMinHeight' => 20, 'eventSources' => [ -- cgit v1.0