From 61003a1e5f712edfe60ed04519d51089ecc6dd70 Mon Sep 17 00:00:00 2001 From: Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> Date: Fri, 24 Jun 2022 05:34:19 +0000 Subject: [PATCH] pass only existing dates to room request, fixes #1214 Closes #1214 Merge request studip/studip!723 --- app/controllers/course/timesrooms.php | 17 ++++++++++++++--- lib/models/resources/ResourceRequest.class.php | 6 +++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/controllers/course/timesrooms.php b/app/controllers/course/timesrooms.php index 081608a7627..f37929ca6ba 100644 --- a/app/controllers/course/timesrooms.php +++ b/app/controllers/course/timesrooms.php @@ -697,13 +697,24 @@ class Course_TimesroomsController extends AuthenticatedController /** - * + * Creates a new room request for the selected dates. */ protected function requestStack($cycle_id) { - $this->cycle_id = $cycle_id; + $appointment_ids = []; + + foreach ($_SESSION['_checked_dates'] as $appointment_id) { + if (CourseDate::exists($appointment_id)) { + $appointment_ids[] = $appointment_id; + } + } + + if (!$appointment_ids) { + PageLayout::postError(_('Es wurden keine gültigen Termin-IDs übergeben!')); + $this->relocate('course/timesrooms/index', ['contentbox_open' => $cycle_id]); + return; + } - $appointment_ids = $_SESSION['_checked_dates']; $this->redirect( 'course/room_requests/request_start', [ diff --git a/lib/models/resources/ResourceRequest.class.php b/lib/models/resources/ResourceRequest.class.php index 6150cf4ed99..f539d646bda 100644 --- a/lib/models/resources/ResourceRequest.class.php +++ b/lib/models/resources/ResourceRequest.class.php @@ -1428,11 +1428,11 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen return sprintf(_('Einzeltermine (%sx)'), count($this->appointments)); } } elseif (count($this->appointments) == 1) { - if ($short) { + $date = $this->appointments[0]->appointment; + if ($short || !$date) { return _('Einzeltermin'); } else { - return sprintf(_('Einzeltermin (%s)'), - $this->appointments[0]->appointment->getFullname()); + return sprintf(_('Einzeltermin (%s)'), $date->getFullname()); } } elseif ($this->date) { if ($short) { -- GitLab