aboutsummaryrefslogtreecommitdiff
path: root/lib/models/resources/ResourceBooking.php
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2025-05-13 06:21:44 +0000
committerMoritz Strohm <strohm@data-quest.de>2025-05-13 06:21:44 +0000
commitc0e48592ef765d3a007f60031adb697afb28204c (patch)
tree003e7d44486c20d1ab9bafb0dd5d1dfbd2a49b84 /lib/models/resources/ResourceBooking.php
parentf207949ed9ad3aabfbdd8132e9fe82b0ad8bb655 (diff)
ResourceBooking::validate: skip exceptions independent of their time range, fixes #5181
Closes #5181 Merge request studip/studip!4114
Diffstat (limited to 'lib/models/resources/ResourceBooking.php')
-rw-r--r--lib/models/resources/ResourceBooking.php26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/models/resources/ResourceBooking.php b/lib/models/resources/ResourceBooking.php
index 41c1867..fa6d5e1 100644
--- a/lib/models/resources/ResourceBooking.php
+++ b/lib/models/resources/ResourceBooking.php
@@ -512,27 +512,27 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
$time_intervals = $this->calculateTimeIntervals(true);
$time_interval_overlaps = [];
- $existing_deleted_intervals = [];
+ $exceptions = [];
if (!$this->isNew()) {
- $existing_deleted_intervals = array_filter(
- $this->getTimeIntervals(),
- function ($i): bool {
- return !$i->takes_place;
- }
+ // Calculate the shift in time of this booking:
+ $exceptions = ResourceBookingInterval::findAndMapBySQL(
+ function (ResourceBookingInterval $interval): string {
+ // Store the date of the exception:
+ return date('Ymd', $interval->begin);
+ },
+ "`booking_id` = :booking_id AND `takes_place` = 0",
+ ['booking_id' => $this->id]
);
}
$course = null;
foreach ($time_intervals as $time_interval) {
- foreach ($existing_deleted_intervals as $deleted_interval) {
- if (
- $time_interval['begin']->getTimestamp() == $deleted_interval['begin']
- && $time_interval['end']->getTimestamp() == $deleted_interval['end']
- ) {
- continue 2;
- }
+ if (in_array($time_interval['begin']->format('Ymd'), $exceptions)) {
+ //Skip this time interval, since it is an exception.
+ continue;
}
+
$is_locked = $derived_resource->isLocked(
$time_interval['begin'],
$time_interval['end'],