From 6581c8019606a2e75ad2fe5f96dbba2514626428 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Thu, 17 Feb 2022 12:43:05 +0100 Subject: [PATCH] SingleCalendar::deleteEventWithConsultation: removed unnecessary check, added check for other users connected to the event --- lib/classes/calendar/SingleCalendar.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/classes/calendar/SingleCalendar.php b/lib/classes/calendar/SingleCalendar.php index ecdb85009a7..ee467fb7989 100644 --- a/lib/classes/calendar/SingleCalendar.php +++ b/lib/classes/calendar/SingleCalendar.php @@ -579,15 +579,15 @@ class SingleCalendar if ($consultation_event) { //Check if the slot is empty and delete it, if so. if ($consultation_event->slot) { - if (!empty($consultation_event->slot->bookings)) { + if (empty($consultation_event->slot->events)) { foreach ($consultation_event->slot->bookings as $booking) { - if ($booking->isDeleted()) { - continue; - } $booking->cancel(); } - $consultation_event->slot->delete(); - return true; + return $consultation_event->slot->delete(); + } else { + //There are other users who are connected to the slot. + //Delete only the event for the user. + return $consultation_event->delete(); } } } -- GitLab