From b2e0f16e9f0bef9a7aa1a82d4bb166234a0423b4 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 20 Dec 2024 08:35:18 +0000 Subject: [PATCH] fix access to room information in admin courses export, fixes #5059 Closes #5059 Merge request studip/studip!3787 --- lib/classes/CourseDateList.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/classes/CourseDateList.php b/lib/classes/CourseDateList.php index 5f6d4b1f10e..8a6be35a305 100644 --- a/lib/classes/CourseDateList.php +++ b/lib/classes/CourseDateList.php @@ -22,12 +22,12 @@ class CourseDateList implements Stringable { /** - * @var array $regular_dates contains regular course dates. + * @var SeminarCycleDate[] $regular_dates contains regular course dates. */ protected array $regular_dates = []; /** - * @var array $single_dates contains single course dates. + * @var CourseDate[] $single_dates contains single course dates. * These can be part of a regular course date, or they can * be irregular dates, depending on the use case of the * CourseDateCollection instance. @@ -35,7 +35,7 @@ class CourseDateList implements Stringable protected array $single_dates = []; /** - * @var array $cancelled_dates contains cancelled course dates. + * @var CourseExDate[] $cancelled_dates contains cancelled course dates. */ protected array $cancelled_dates = []; @@ -249,7 +249,7 @@ class CourseDateList implements Stringable $output[] = $date_line; } else { //Group by rooms. - if (!is_array($output[$room->name])) { + if (!isset($output[$room->name])) { $output[$room->name] = []; } $output[$room->name][] = $date_line; @@ -257,7 +257,7 @@ class CourseDateList implements Stringable } elseif ($group_by_rooms) { //Use the "null" room name: $null_room_name = _('Kein Raum'); - if (!is_array($output[$null_room_name])) { + if (!isset($output[$null_room_name])) { $output[$null_room_name] = []; } $output[$null_room_name][] = $date_line; @@ -270,10 +270,12 @@ class CourseDateList implements Stringable $date_line = $single_date->getFullName($with_room_names ? 'long-include-room' : 'long'); if ($group_by_rooms) { $room_name = _('Kein Raum'); - if ($single_date->room instanceof Room) { - $room_name = $single_date->room->name; + if ($single_date->room_booking) { + $room_name = $single_date->room_booking->room_name; + } elseif ($single_date->raum) { + $room_name = $single_date->raum; } - if (!is_array($output[$room_name])) { + if (!isset($output[$room_name])) { $output[$room_name] = []; } $output[$room_name][] = $date_line; @@ -285,7 +287,7 @@ class CourseDateList implements Stringable foreach ($this->cancelled_dates as $cancelled_date) { if ($group_by_rooms) { $room_name = _('Kein Raum'); - if (!is_array($output[$room_name])) { + if (!isset($output[$room_name])) { $output[$room_name] = []; } $output[$room_name][] = $cancelled_date->toString(); -- GitLab