From 707bbb23d954cbec887374ed578e8783d84d3647 Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Thu, 30 Nov 2023 10:22:44 +0000
Subject: [PATCH] prevent error, closes #3521

Closes #3521

Merge request studip/studip!2406
---
 lib/models/CourseEvent.class.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/models/CourseEvent.class.php b/lib/models/CourseEvent.class.php
index 2d564b5dd4f..e33532dc7da 100644
--- a/lib/models/CourseEvent.class.php
+++ b/lib/models/CourseEvent.class.php
@@ -140,12 +140,15 @@ class CourseEvent extends CourseDate implements Event
     /**
      * Returns the name of the category.
      *
-     * @return string the name of the category
+     * @return array|string the name of the category
      */
     public function toStringCategories($as_array = false)
     {
         $category = '';
-        if ($this->havePermission(Event::PERMISSION_READABLE)) {
+        if (
+            $this->havePermission(Event::PERMISSION_READABLE)
+            && !empty($GLOBALS['TERMIN_TYP'][$this->getCategory()])
+        ) {
             $category = $GLOBALS['TERMIN_TYP'][$this->getCategory()]['name'];
         }
         return $as_array ? [$category] : $category;
-- 
GitLab