From 1c8e0aa4f83cfc2ddfc982f4683af8115974cbb8 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Thu, 17 Oct 2024 06:37:06 +0000
Subject: [PATCH] add type to consultation events, fixes #4703

Closes #4703

Merge request studip/studip!3498
---
 lib/models/ConsultationBooking.php |  2 +-
 lib/models/ConsultationSlot.php    | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/models/ConsultationBooking.php b/lib/models/ConsultationBooking.php
index 7782681fa45..17cb236f50c 100644
--- a/lib/models/ConsultationBooking.php
+++ b/lib/models/ConsultationBooking.php
@@ -47,7 +47,7 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject
         $config['registered_callbacks']['before_create'][] = function (ConsultationBooking $booking) {
             setTempLanguage($booking->user_id);
 
-            $event = $booking->slot->createEvent($booking->user);
+            $event = $booking->slot->createEvent($booking->user, 'booking');
             $event->category = 1;
             $event->title = sprintf(
                 _('Termin bei %s'),
diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php
index 520b91e1021..e078914c61e 100644
--- a/lib/models/ConsultationSlot.php
+++ b/lib/models/ConsultationSlot.php
@@ -214,12 +214,13 @@ class ConsultationSlot extends SimpleORMap
      * Creates a Stud.IP calendar event relating to the slot.
      *
      * @param  User $user User object to create the event for
+     * @param string $type Create an event for which type (slot or booking)
      * @return CalendarDate Created event
      */
-    public function createEvent(User $user) : CalendarDate
+    public function createEvent(User $user, string $type = 'slot') : CalendarDate
     {
         $event = new CalendarDate();
-        $event->unique_id = $this->createEventId($user);
+        $event->unique_id = $this->createEventId($user, $type);
         $event->author_id = $user->id;
         $event->editor_id = $user->id;
         $event->begin     = $this->start_time;
@@ -244,12 +245,11 @@ class ConsultationSlot extends SimpleORMap
     /**
      * Returns a unique event id.
      *
-     * @param  User $user [description]
      * @return string unique event id
      */
-    protected function createEventId(User $user): string
+    protected function createEventId(User $user, string $type): string
     {
-        return self::EVENT_PREFIX . "{$this->id}:{$user->id}";
+        return self::EVENT_PREFIX . "{$this->id}:{$user->id}:{$type}";
     }
 
     /**
-- 
GitLab