From 50d0882856c692bbe2880374e81d5a67eea7ce65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de>
Date: Mon, 18 Mar 2024 16:56:45 +0000
Subject: [PATCH] Resolve #3837 "ICAL Export fehlt das UID Attribut"

Closes #3837

Merge request studip/studip!2704
---
 lib/classes/calendar/ICalendarExport.class.php | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/classes/calendar/ICalendarExport.class.php b/lib/classes/calendar/ICalendarExport.class.php
index 01fe541ea47..ce50f872eeb 100644
--- a/lib/classes/calendar/ICalendarExport.class.php
+++ b/lib/classes/calendar/ICalendarExport.class.php
@@ -149,7 +149,8 @@ class ICalendarExport
                 'count'     => $date->number_of_dates,
                 'expire'    => $date->repetition_end,
                 'month'     => $date->month
-            ]
+            ],
+            'UID'           => $date->unique_id
         ];
     }
 
@@ -159,17 +160,24 @@ class ICalendarExport
      */
     public function prepareCourseDate($date): array
     {
+        $summary = $date->course->getFullName();
+        $categories = $date->getTypeName();
+        if ($date instanceof CourseExDate) {
+            $summary .= ' ' . _('(fällt aus)');
+            $categories = '';
+        }
         return [
-            'SUMMARY'       => $date->course->getFullName(),
+            'SUMMARY'       => $summary,
             'DESCRIPTION'   => '',
             'LOCATION'      => $date->getRoomName(),
-            'CATEGORIES'    => $GLOBALS['TERMIN_TYP'][$date->date_typ]['name'],
+            'CATEGORIES'    => $categories,
             'LAST-MODIFIED' => $date->chdate,
             'CREATED'       => $date->mkdate,
             'DTSTAMP'       => $this->time,
             'DTSTART'       => $date->date,
             'DTEND'         => $date->end_time,
-            'PRIORITY'      => ''
+            'PRIORITY'      => '',
+            'UID'           => 'Stud.IP-SEM-' . $date->id . '@' . ($_SERVER['SERVER_NAME'] ?? '')
         ];
     }
 
-- 
GitLab