From ce63777244a4fa83fda033cd9c9733b1f17e53f7 Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Wed, 3 Apr 2024 08:22:24 +0000
Subject: [PATCH] calendar/date/add: add the calendar owner instead of the
 current user as default participant, fixes #3923

Closes #3923

Merge request studip/studip!2777
---
 app/controllers/calendar/date.php | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/app/controllers/calendar/date.php b/app/controllers/calendar/date.php
index 72f3a405931..eda171b94a8 100644
--- a/app/controllers/calendar/date.php
+++ b/app/controllers/calendar/date.php
@@ -27,9 +27,8 @@ class Calendar_DateController extends AuthenticatedController
             $range_id = $range_and_id[1];
         }
         if (!$range) {
-            //Show the personal calendar of the current user:
+            $range_id = Request::option('user_id', $GLOBALS['user']->id);
             $range = 'user';
-            $range_id = $GLOBALS['user']->id;
         }
 
         $owner = null;
@@ -325,15 +324,12 @@ class Calendar_DateController extends AuthenticatedController
 
         if ($this->date->isNew()) {
             if (!($owner instanceof Course)) {
-                //Assign the date to the calendar of the current user by default:
-                $user = User::findCurrent();
-                if ($user) {
-                    $this->calendar_assignment_items[] = [
-                        'value'     => $user->id,
-                        'name'      => $user->getFullName(),
-                        'deletable' => true
-                    ];
-                }
+                //Assign the date to the calendar of the owner by default:
+                $this->calendar_assignment_items[] = [
+                    'value'     => $owner->id,
+                    'name'      => $owner->getFullName(),
+                    'deletable' => true
+                ];
             }
         } else {
             $exceptions = CalendarDateException::findBySql(
-- 
GitLab