diff --git a/lib/models/ConsultationEvent.php b/lib/models/ConsultationEvent.php index e0b6b5962cddb3a58ba8e8bba2d98e88db63d190..fe8a4051a49c6be9a8ae73f15bd90cc13b42c8db 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); } } diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php index 5a59208c8a409acaf28c1f444fa72dba39b5aeff..520b91e10218f9a1ad4318a4116492bc2f652705 100644 --- a/lib/models/ConsultationSlot.php +++ b/lib/models/ConsultationSlot.php @@ -232,6 +232,10 @@ class ConsultationSlot extends SimpleORMap $calendar_event = new CalendarDateAssignment(); $calendar_event->range_id = $user->id; $calendar_event->calendar_date_id = $event->id; + + // Suppress mails for users that do not want mails from the consultations + $calendar_event->suppress_mails = !$user->getConfiguration()->CONSULTATION_SEND_MESSAGES; + $calendar_event->store(); return $event; diff --git a/lib/models/calendar/CalendarDate.php b/lib/models/calendar/CalendarDate.php index b3608b698fcbfd918a6f8da9083fa3b1941bce0d..fcdd65cef1cde1b43d5f8c209b4aa5881ad92397 100644 --- a/lib/models/calendar/CalendarDate.php +++ b/lib/models/calendar/CalendarDate.php @@ -38,6 +38,11 @@ * @property string mkdate database column * @property string chdate database column * @property string import_date database column + * + * @property User $author + * @property User $editor + * @property CalendarDateAssignment[]|SimpleORMapCollection $calendars + * @property CalendarDateException[]|SimpleORMapCollection $exceptions */ class CalendarDate extends SimpleORMap implements PrivacyObject { diff --git a/lib/models/calendar/CalendarDateAssignment.php b/lib/models/calendar/CalendarDateAssignment.php index 82bbab88678fee41ec42669a487e3a5f9b89fd4f..d61d124bf8b90c38e96a2398a23070144ea87247 100644 --- a/lib/models/calendar/CalendarDateAssignment.php +++ b/lib/models/calendar/CalendarDateAssignment.php @@ -29,6 +29,8 @@ * @property string mkdate The creation date of the assignment. * @property string chdate The modification date of the assignment. * @property CalendarDate|null calendar_date The associated calendar date object. + * @property User|null $user + * @property Course|null $course */ class CalendarDateAssignment extends SimpleORMap implements Event {