diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-09-03 13:16:04 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2024-09-03 15:49:16 +0200 |
| commit | 33dbf42c29ba9ce5f51098f37a6743a00bb03f8b (patch) | |
| tree | 12bc77c669c0ff3476625ff24bd1eafec9d1e870 /lib/models/ConsultationEvent.php | |
| parent | 23ad91828e26e38df1bcc4a0f3a418cae209f4e5 (diff) | |
prevent all mails from consultation bookings, fixes #4532
Closes #4532
Merge request studip/studip!3336
Diffstat (limited to 'lib/models/ConsultationEvent.php')
| -rw-r--r-- | lib/models/ConsultationEvent.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/models/ConsultationEvent.php b/lib/models/ConsultationEvent.php index eac2d28..4f51f0b 100644 --- a/lib/models/ConsultationEvent.php +++ b/lib/models/ConsultationEvent.php @@ -29,6 +29,24 @@ class ConsultationEvent extends SimpleORMap 'on_delete' => 'delete', ]; + $config['registered_callbacks'] = [ + 'before_delete' => [ + function (ConsultationEvent $event) { + // Suppress all mails from calendar for users that do not + // want to receive emails about consultation bookings + $event->event->calendars->each(function (CalendarDateAssignment $assignment) { + if ( + $assignment->user + && !$assignment->user->getConfiguration()->CONSULTATION_SEND_MESSAGES + ) { + $assignment->suppress_mails = true; + $assignment->delete(); + } + }); + }, + ], + ]; + parent::configure($config); } } |
