aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2026-01-30 09:42:10 +0000
committerMoritz Strohm <strohm@data-quest.de>2026-01-30 09:42:10 +0000
commit991f2829e266bfcaf51fbf465e3ed82887770bc6 (patch)
treec2fbb82fcf985789d3c7f29101f5a7f978bfa5a0 /lib
parent8eff2fe1f2943e2e52aae6d209cddaaf68d2307e (diff)
added a valid range for the navigation in the day view of the schedule, fixes #6104
Closes #6104 Merge request studip/studip!4700
Diffstat (limited to 'lib')
-rw-r--r--lib/classes/calendar/Helper.php25
1 files 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' => [