From 3bd5d835d9024d56a0cdce56cb5d53a09364b5c1 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Mon, 5 Sep 2022 13:35:57 +0000 Subject: [PATCH] do not allow copying a booking into its resource, closes #840 Closes #840 Merge request studip/studip!943 --- app/controllers/resources/booking.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/resources/booking.php b/app/controllers/resources/booking.php index 72b28040e50..28894494075 100644 --- a/app/controllers/resources/booking.php +++ b/app/controllers/resources/booking.php @@ -1550,13 +1550,19 @@ class Resources_BookingController extends AuthenticatedController $this->show_form = false; - $this->available_resources = ResourceManager::getUserResources( + $unfiltered_available_resources = ResourceManager::getUserResources( $current_user, 'autor', null, [$this->booking->resource->class_name], true ); + //Filter out the resource of the booking since we only want to allow copying the + //booking into other resources: + $booking_resource_id = $this->booking->resource_id; + $this->available_resources = array_filter($unfiltered_available_resources, function ($item) use ($booking_resource_id) { + return $item->id !== $booking_resource_id; + }); $this->show_form = true; -- GitLab