Skip to content
Snippets Groups Projects
Commit c1231362 authored by Moritz Strohm's avatar Moritz Strohm Committed by Jan-Hendrik Willms
Browse files

ConsultationEvent::before_delete: do not send mails when deleting calendar...

ConsultationEvent::before_delete: do not send mails when deleting calendar date assignments when they lie in the past, fixes #5561

Closes #5561

Merge request !4181
parent 3b472b87
No related branches found
No related tags found
No related merge requests found
Pipeline #33046 passed
...@@ -36,16 +36,21 @@ class ConsultationEvent extends SimpleORMap ...@@ -36,16 +36,21 @@ class ConsultationEvent extends SimpleORMap
return; return;
} }
// Suppress all mails from calendar for users that do not // Suppress all mails from calendar for users that do not want to receive emails about
// want to receive emails about consultation bookings // consultation bookings or for calendar dates that lie in the past.
$event->event->calendars->each(function (CalendarDateAssignment $assignment) { $event->event->calendars->each(function (CalendarDateAssignment $assignment) {
if ( if (
$assignment->user empty($assignment->calendar_date->end)
&& !$assignment->user->getConfiguration()->CONSULTATION_SEND_MESSAGES || $assignment->calendar_date->end < time()
|| (
$assignment->user
&& !$assignment->user->getConfiguration()->CONSULTATION_SEND_MESSAGES
)
) { ) {
$assignment->suppress_mails = true; $assignment->suppress_mails = true;
$assignment->delete();
} }
$assignment->delete();
}); });
}, },
], ],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment