Skip to content
Snippets Groups Projects
Commit 89c22235 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

ensure booking is valid before updating event, fixes #1300

Closes #1300

Merge request studip/studip!798
parent 3e3c02f3
No related branches found
No related tags found
No related merge requests found
...@@ -204,11 +204,19 @@ class ConsultationSlot extends SimpleORMap ...@@ -204,11 +204,19 @@ class ConsultationSlot extends SimpleORMap
// If no range is associated, remove the event // If no range is associated, remove the event
if (!$this->block->range) { if (!$this->block->range) {
return $this->removeEvent(); $this->removeEvent();
return;
} }
if (count($this->bookings) === 0 && !$this->block->calendar_events) { $bookings = $this->bookings->filter(function (ConsultationBooking $booking) {
return $this->removeEvent(); return !$booking->isDeleted()
&& $booking->user;
});
if (count($bookings) === 0 && !$this->block->calendar_events) {
$this->removeEvent();
return;
} }
$event = $this->event; $event = $this->event;
...@@ -221,11 +229,11 @@ class ConsultationSlot extends SimpleORMap ...@@ -221,11 +229,11 @@ class ConsultationSlot extends SimpleORMap
setTempLanguage($this->block->range_id); setTempLanguage($this->block->range_id);
if (count($this->bookings) > 0) { if (count($bookings) > 0) {
$event->category_intern = 1; $event->category_intern = 1;
if (count($this->bookings) === 1) { if (count($bookings) === 1) {
$booking = $this->bookings->first(); $booking = $bookings->first();
$event->summary = sprintf( $event->summary = sprintf(
_('Termin mit %s'), _('Termin mit %s'),
...@@ -235,9 +243,9 @@ class ConsultationSlot extends SimpleORMap ...@@ -235,9 +243,9 @@ class ConsultationSlot extends SimpleORMap
} else { } else {
$event->summary = sprintf( $event->summary = sprintf(
_('Termin mit %u Personen'), _('Termin mit %u Personen'),
count($this->bookings) count($bookings)
); );
$event->description = implode("\n\n----\n\n", $this->bookings->map(function ($booking) { $event->description = implode("\n\n----\n\n", $bookings->map(function ($booking) {
return "- {$booking->user->getFullName()}:\n{$booking->reason}"; return "- {$booking->user->getFullName()}:\n{$booking->reason}";
})); }));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment