Skip to content
Snippets Groups Projects
Commit f0eef2f1 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

prevent all mails from consultation bookings, fixes #4532

Closes #4532

Merge request studip/studip!3336
parent ca495223
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,24 @@ class ConsultationEvent extends SimpleORMap ...@@ -29,6 +29,24 @@ class ConsultationEvent extends SimpleORMap
'on_delete' => 'delete', '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); parent::configure($config);
} }
} }
...@@ -232,6 +232,10 @@ class ConsultationSlot extends SimpleORMap ...@@ -232,6 +232,10 @@ class ConsultationSlot extends SimpleORMap
$calendar_event = new CalendarDateAssignment(); $calendar_event = new CalendarDateAssignment();
$calendar_event->range_id = $user->id; $calendar_event->range_id = $user->id;
$calendar_event->calendar_date_id = $event->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(); $calendar_event->store();
return $event; return $event;
......
...@@ -38,6 +38,11 @@ ...@@ -38,6 +38,11 @@
* @property string mkdate database column * @property string mkdate database column
* @property string chdate database column * @property string chdate database column
* @property string import_date 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 class CalendarDate extends SimpleORMap implements PrivacyObject
{ {
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
* @property string mkdate The creation date of the assignment. * @property string mkdate The creation date of the assignment.
* @property string chdate The modification date of the assignment. * @property string chdate The modification date of the assignment.
* @property CalendarDate|null calendar_date The associated calendar date object. * @property CalendarDate|null calendar_date The associated calendar date object.
* @property User|null $user
* @property Course|null $course
*/ */
class CalendarDateAssignment extends SimpleORMap implements Event class CalendarDateAssignment extends SimpleORMap implements Event
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment