aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2025-04-25 13:21:19 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2025-04-25 15:38:15 +0200
commitdbc0a7ffc01c512ca7cdbfc3f2ccf2798abcdeba (patch)
treef0e7da51528d8f1dc2dbaf3cae243ae8b18b8222
parentbc6bc09738e22182a1d691f05d3cbe133253f6d0 (diff)
ConsultationEvent::before_delete: do not send mails when deleting calendar date assignments when they lie in the past, fixes #5561
Closes #5561 Merge request studip/studip!4181
-rw-r--r--lib/models/ConsultationEvent.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/models/ConsultationEvent.php b/lib/models/ConsultationEvent.php
index c182443..2a856c9 100644
--- a/lib/models/ConsultationEvent.php
+++ b/lib/models/ConsultationEvent.php
@@ -36,16 +36,21 @@ class ConsultationEvent extends SimpleORMap
return;
}
- // Suppress all mails from calendar for users that do not
- // want to receive emails about consultation bookings
+ // Suppress all mails from calendar for users that do not want to receive emails about
+ // consultation bookings or for calendar dates that lie in the past.
$event->event->calendars->each(function (CalendarDateAssignment $assignment) {
if (
- $assignment->user
- && !$assignment->user->getConfiguration()->CONSULTATION_SEND_MESSAGES
+ empty($assignment->calendar_date->end)
+ || $assignment->calendar_date->end < time()
+ || (
+ $assignment->user
+ && !$assignment->user->getConfiguration()->CONSULTATION_SEND_MESSAGES
+ )
+
) {
$assignment->suppress_mails = true;
- $assignment->delete();
}
+ $assignment->delete();
});
},
],