aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/models/ConsultationBooking.php2
-rw-r--r--lib/models/ConsultationSlot.php8
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/models/ConsultationBooking.php b/lib/models/ConsultationBooking.php
index 3e02ba0..7a5e015 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 1177fce..a271a75 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) {