Skip to content
Snippets Groups Projects
Commit dd008ac0 authored by David Siegfried's avatar David Siegfried Committed by Jan-Hendrik Willms
Browse files

prevent php-warnings in resources, fixes #4623

Closes #4623

Merge request !3435
parent 3ec7589b
Branches
No related tags found
No related merge requests found
...@@ -1296,7 +1296,6 @@ class Resources_RoomRequestController extends AuthenticatedController ...@@ -1296,7 +1296,6 @@ class Resources_RoomRequestController extends AuthenticatedController
} else { } else {
//If no room is selected, it cannot be declared fully available. //If no room is selected, it cannot be declared fully available.
$this->requested_room_fully_available = false; $this->requested_room_fully_available = false;
$this->room_availability_share[$selected_room->id] = 0.0;
} }
//Load the room groups of the current user: //Load the room groups of the current user:
...@@ -1452,7 +1451,8 @@ class Resources_RoomRequestController extends AuthenticatedController ...@@ -1452,7 +1451,8 @@ class Resources_RoomRequestController extends AuthenticatedController
$deduplicated = []; $deduplicated = [];
foreach ($this->alternative_rooms as $room) { foreach ($this->alternative_rooms as $room) {
if ($room->id != $this->request_resource->id if (
(!$this->request_resource || $room->id !== $this->request_resource->id)
&& !isset($deduplicated[$room->id]) && !isset($deduplicated[$room->id])
) { ) {
$deduplicated[$room->id] = $room; $deduplicated[$room->id] = $room;
...@@ -1556,7 +1556,7 @@ class Resources_RoomRequestController extends AuthenticatedController ...@@ -1556,7 +1556,7 @@ class Resources_RoomRequestController extends AuthenticatedController
return; return;
} }
if ($course_date->room_booking->resource_id != $room_id) { if ($course_date->room_booking && $course_date->room_booking->resource_id !== $room_id) {
try { try {
$booking = $room->createBooking( $booking = $room->createBooking(
$this->current_user, $this->current_user,
...@@ -1574,7 +1574,7 @@ class Resources_RoomRequestController extends AuthenticatedController ...@@ -1574,7 +1574,7 @@ class Resources_RoomRequestController extends AuthenticatedController
); );
if ($booking instanceof ResourceBooking) { if ($booking instanceof ResourceBooking) {
$bookings[] = $booking; $bookings[] = $booking;
if ($this->booked_room_infos[$room->id]) { if (!empty($this->booked_room_infos[$room->id])) {
if ($this->booked_room_infos[$room->id]['first_booking_date'] > $booking->begin) { if ($this->booked_room_infos[$room->id]['first_booking_date'] > $booking->begin) {
$this->booked_room_infos[$room->id]['first_booking_date'] = $booking->begin; $this->booked_room_infos[$room->id]['first_booking_date'] = $booking->begin;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<label> <label>
<?= _('Ausgewählte Raumkategorie') ?> <?= _('Ausgewählte Raumkategorie') ?>
<input type="hidden" name="selected_room_id" <input type="hidden" name="selected_room_id"
value="<?= htmlReady($selected_room->id) ?>"> value="<?= htmlReady($selected_room ? $selected_room->id : '') ?>">
<br> <br>
<strong><?= htmlReady($selected_room_category->name) ?></strong> <strong><?= htmlReady($selected_room_category->name) ?></strong>
......
...@@ -121,8 +121,7 @@ ...@@ -121,8 +121,7 @@
<? endif ?> <? endif ?>
<? elseif ($booking->getAssignedUserType() === 'user') : ?> <? elseif ($booking->getAssignedUserType() === 'user') : ?>
<? if (($booking->assigned_user->visible === 'yes') || <? if (($booking->assigned_user->visible === 'yes') ||
($booking->assigned_user->id === $GLOBALS['user']->id) || ($booking->assigned_user->id === $GLOBALS['user']->id) || !empty($user_has_user_perms)) : ?>
$user_has_user_perms) : ?>
<h3><?= _('Gebucht für:') ?></h3> <h3><?= _('Gebucht für:') ?></h3>
<a href="<?= URLHelper::getScriptLink( <a href="<?= URLHelper::getScriptLink(
'dispatch.php/profile', 'dispatch.php/profile',
......
...@@ -964,8 +964,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -964,8 +964,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
$date = CourseDate::find($appointment->appointment_id); $date = CourseDate::find($appointment->appointment_id);
$interval['range'] = 'CourseDate'; $interval['range'] = 'CourseDate';
$interval['range_id'] = $appointment->appointment_id; $interval['range_id'] = $appointment->appointment_id;
$interval['booked_room'] = $date->room_booking->resource_id; $interval['booked_room'] = $date->room_booking->resource_id ?? '';
$interval['booking_id'] = $date->room_booking->id; $interval['booking_id'] = $date->room_booking->id ?? '';
$time_intervals['']['intervals'][] = $interval; $time_intervals['']['intervals'][] = $interval;
} }
...@@ -2433,7 +2433,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -2433,7 +2433,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
{ {
$props = ''; $props = '';
foreach ($this->getPropertyData() as $name => $state) { foreach ($this->getPropertyData() as $name => $state) {
$props .= $name . '=' . $state . ' '; $props .= $name . '=' . json_encode($state) . ' ';
} }
$info['Anfrage'] = $this->getType(); $info['Anfrage'] = $this->getType();
$info['Status'] = $this->getStatus(); $info['Status'] = $this->getStatus();
......
...@@ -667,17 +667,17 @@ class RoomManager ...@@ -667,17 +667,17 @@ class RoomManager
//Furthermore we must check if only minimum or maximum are //Furthermore we must check if only minimum or maximum are
//set or if both are set. Depending on that condition, //set or if both are set. Depending on that condition,
//the conditions are different. //the conditions are different.
if ($state[0] && $state[1]) { if (!empty($state[0]) && !empty($state[1])) {
//Minimum and maximum are specified: //Minimum and maximum are specified:
if ($room_prop_state >= $state[0] && $room_prop_state <= $state[1]) { if ($room_prop_state >= $state[0] && $room_prop_state <= $state[1]) {
$room_property_match++; $room_property_match++;
} }
} elseif ($state[0]) { } elseif (!empty($state[0])) {
//Only a minimum is given: //Only a minimum is given:
if ($room_prop_state >= $state[0]) { if ($room_prop_state >= $state[0]) {
$room_property_match++; $room_property_match++;
} }
} elseif ($state[1]) { } elseif (!empty($state[1])) {
//Only a maximum is given: //Only a maximum is given:
if ($room_prop_state <= $state[1]) { if ($room_prop_state <= $state[1]) {
$room_property_match++; $room_property_match++;
......
...@@ -8,8 +8,9 @@ Lehrende Person(en): <?= $lecturer_names ?> ...@@ -8,8 +8,9 @@ Lehrende Person(en): <?= $lecturer_names ?>
<? endif ?> <? endif ?>
<? if ($request->resource) : ?>
Angefragter Raum: <?= $request->resource->name ?> Angefragter Raum: <?= $request->resource->name ?>
<? endif ?>
Gebuchte Räume: <?= $booked_rooms ?> Gebuchte Räume: <?= $booked_rooms ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment