diff --git a/lib/models/ConsultationBooking.php b/lib/models/ConsultationBooking.php index 3e02ba014ce308c870938ab00926b9e6ab480940..7a5e0150a3588573602a64637ab9d8249694ee54 100644 --- a/lib/models/ConsultationBooking.php +++ b/lib/models/ConsultationBooking.php @@ -88,7 +88,7 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject }; $config['registered_callbacks']['after_delete'][] = function (ConsultationBooking $booking) { - $booking->slot->updateEvents(); + $booking->slot->updateEvents(true); }; parent::configure($config); diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php index 1177fcec98f986028dfaae5dac96614eb713d448..a271a75dec202712ce73b04d8ec9cfcbbd1a05ad 100644 --- a/lib/models/ConsultationSlot.php +++ b/lib/models/ConsultationSlot.php @@ -190,8 +190,11 @@ class ConsultationSlot extends SimpleORMap /** * Updates the teacher event that belongs to the slot. This will either be * set to be unoccupied, occupied by only one user or by a group of user. + * + * @param bool $delete_action Whether this method is called from a delete action (true) + * or not (false). Defaults to false. */ - public function updateEvents() + public function updateEvents(bool $delete_action = false) { // If no range is associated, remove the event if (!$this->block->range) { @@ -219,6 +222,9 @@ class ConsultationSlot extends SimpleORMap } } + if ($delete_action) { + return; + } // Add events for missing responsible users $missing = array_diff($responsible_ids, $this->events->pluck('user_id')); foreach ($missing as $user_id) {