From 4523edd7020606dcd9f85b12d1812f642853b54d Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 27 Jun 2022 10:56:21 +0000
Subject: [PATCH] set booking user to current user if resource booking is
 changed or if the user is invalid, fixes #1220

Closes #1220

Merge request studip/studip!729
---
 lib/models/resources/ResourceBooking.class.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/models/resources/ResourceBooking.class.php b/lib/models/resources/ResourceBooking.class.php
index dac56ad5d1d..5f3dd5e0f32 100644
--- a/lib/models/resources/ResourceBooking.class.php
+++ b/lib/models/resources/ResourceBooking.class.php
@@ -466,8 +466,10 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
         }
 
         // update the booking user
-        $this->booking_user = User::findCurrent();
-    
+        if (!$this->isNew() || !$this->booking_user_id) {
+            $this->booking_user = User::findCurrent();
+        }
+
         //Check if the user has booking rights on the resource.
         //The user must have either permanent permissions or they have to
         //have booking rights by a temporary permission in this moment
-- 
GitLab