aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-09-03 13:16:04 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2024-09-03 13:16:04 +0000
commitf0eef2f1a2b91ca694d978b9feda208de26e867d (patch)
tree23f79158fe545277226ff7be1af22a06bd649378
parentca49522373c5b393d271971765adc1acbee158ec (diff)
prevent all mails from consultation bookings, fixes #4532
Closes #4532 Merge request studip/studip!3336
-rw-r--r--lib/models/ConsultationEvent.php18
-rw-r--r--lib/models/ConsultationSlot.php4
-rw-r--r--lib/models/calendar/CalendarDate.php5
-rw-r--r--lib/models/calendar/CalendarDateAssignment.php2
4 files changed, 29 insertions, 0 deletions
diff --git a/lib/models/ConsultationEvent.php b/lib/models/ConsultationEvent.php
index e0b6b59..fe8a405 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 5a59208..520b91e 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 b3608b6..fcdd65c 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 82bbab8..d61d124 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
{