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

fix room-request, re #3825

Merge request studip/studip!2693
parent 3fff4b9d
No related branches found
No related tags found
No related merge requests found
...@@ -233,7 +233,7 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -233,7 +233,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->room_name = $_SESSION[$request_id]['room_name']; $this->room_name = $_SESSION[$request_id]['room_name'];
$this->request = new RoomRequest($this->request_id); $this->request = new RoomRequest($this->request_id);
$this->request->setRangeFields($_SESSION[$this->request_id]['range'], $_SESSION[$this->request_id]['range_ids']); $this->request->setRangeFields($_SESSION[$this->request_id]['range'], $_SESSION[$this->request_id]['range_ids'] ?? []);
$search_properties = $_SESSION[$request_id]['selected_properties'] ?? []; $search_properties = $_SESSION[$request_id]['selected_properties'] ?? [];
...@@ -340,7 +340,6 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -340,7 +340,6 @@ class Course_RoomRequestsController extends AuthenticatedController
if (Request::submitted('search_rooms')) { if (Request::submitted('search_rooms')) {
$this->selected_properties = Request::getArray('selected_properties'); $this->selected_properties = Request::getArray('selected_properties');
$_SESSION[$request_id]['selected_properties'] = $this->selected_properties; $_SESSION[$request_id]['selected_properties'] = $this->selected_properties;
// no min number of seats // no min number of seats
if ( if (
(!$_SESSION[$request_id]['selected_properties']['seats'] || $_SESSION[$request_id]['selected_properties']['seats'] < 1) (!$_SESSION[$request_id]['selected_properties']['seats'] || $_SESSION[$request_id]['selected_properties']['seats'] < 1)
...@@ -408,7 +407,7 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -408,7 +407,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->selected_room = Resource::find($_SESSION[$request_id]['room_id'] ?: $this->request->resource_id); $this->selected_room = Resource::find($_SESSION[$request_id]['room_id'] ?: $this->request->resource_id);
$this->category = $this->room_category_id ? ResourceCategory::find($this->room_category_id) : ''; $this->category = $this->room_category_id ? ResourceCategory::find($this->room_category_id) : '';
$this->available_properties = $this->room_category_id ? $this->category->getRequestableProperties() : ''; $this->available_properties = $this->room_category_id ? $this->category->getRequestableProperties() : '';
$this->selected_properties = $_SESSION[$request_id]['selected_properties']; $this->selected_properties = $_SESSION[$request_id]['selected_properties'] ?? [];
$this->course = Course::find($this->course_id); $this->course = Course::find($this->course_id);
$this->selected_properties['seats'] = $_SESSION[$request_id]['selected_properties']['seats'] $this->selected_properties['seats'] = $_SESSION[$request_id]['selected_properties']['seats']
...@@ -530,8 +529,10 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -530,8 +529,10 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->redirect('course/room_requests/request_show_summary/' . $this->request_id ); $this->redirect('course/room_requests/request_show_summary/' . $this->request_id );
} else { } else {
$room = Room::find($_SESSION[$request_id]['room_id']);
$this->step = 2; $this->step = 2;
$this->request = new RoomRequest($this->request_id); $this->request = new RoomRequest($this->request_id);
$_SESSION[$request_id]['room_category_id'] = $room->category_id;
$this->redirect( $this->redirect(
'course/room_requests/request_find_matching_rooms/' . $this->request_id . '/' . $this->step 'course/room_requests/request_find_matching_rooms/' . $this->request_id . '/' . $this->step
); );
......
...@@ -226,9 +226,9 @@ ...@@ -226,9 +226,9 @@
<? if (Request::isXhr() && !$locked && Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS): ?> <? if (Request::isXhr() && !$locked && Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS): ?>
<? ?> <? ?>
<?= Studip\LinkButton::create( <?= Studip\LinkButton::create(
($request_id ? _('Zur Raumanfrage wechseln') : _('Raumanfrage erstellen')), (isset($request_id) ? _('Zur Raumanfrage wechseln') : _('Raumanfrage erstellen')),
( (
$request_id isset($request_id)
? $controller->url_for( ? $controller->url_for(
'course/room_requests/request_show_summary/' . $request_id 'course/room_requests/request_show_summary/' . $request_id
) )
......
...@@ -154,7 +154,7 @@ class ResourcePropertyDefinition extends SimpleORMap ...@@ -154,7 +154,7 @@ class ResourcePropertyDefinition extends SimpleORMap
? $special_name ? $special_name
: 'properties[' . $this->id . ']'; : 'properties[' . $this->id . ']';
if ($type == 'bool') { if ($type === 'bool') {
$label_html_classes = 'col-3'; $label_html_classes = 'col-3';
//Booleans can have one or two input elements, //Booleans can have one or two input elements,
//whether a false state shall be selectable or not. //whether a false state shall be selectable or not.
...@@ -188,7 +188,7 @@ class ResourcePropertyDefinition extends SimpleORMap ...@@ -188,7 +188,7 @@ class ResourcePropertyDefinition extends SimpleORMap
} else { } else {
return $input_html; return $input_html;
} }
} elseif ($type == 'select') { } elseif ($type === 'select') {
$options_html = sprintf( $options_html = sprintf(
'<option value="" %2$s>%1$s</option>', '<option value="" %2$s>%1$s</option>',
_('Bitte wählen'), _('Bitte wählen'),
...@@ -220,7 +220,7 @@ class ResourcePropertyDefinition extends SimpleORMap ...@@ -220,7 +220,7 @@ class ResourcePropertyDefinition extends SimpleORMap
$options_html $options_html
); );
} }
} elseif ($type == 'position') { } elseif ($type === 'position') {
$factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH']); $factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH']);
$template = $factory->open('templates/resources/position_attribute_form_part.php'); $template = $factory->open('templates/resources/position_attribute_form_part.php');
$template->set_attribute( $template->set_attribute(
...@@ -241,7 +241,7 @@ class ResourcePropertyDefinition extends SimpleORMap ...@@ -241,7 +241,7 @@ class ResourcePropertyDefinition extends SimpleORMap
); );
return $template->render(); return $template->render();
} elseif ($type == 'user') { } elseif ($type === 'user') {
$search = new QuickSearch($input_name, new StandardSearch('user_id')); $search = new QuickSearch($input_name, new StandardSearch('user_id'));
$search->defaultValue($value, ($value ? get_fullname($value, 'full_rev_username') : '')); $search->defaultValue($value, ($value ? get_fullname($value, 'full_rev_username') : ''));
return sprintf( return sprintf(
...@@ -265,12 +265,14 @@ class ResourcePropertyDefinition extends SimpleORMap ...@@ -265,12 +265,14 @@ class ResourcePropertyDefinition extends SimpleORMap
); );
} else { } else {
$input_type = 'text'; $input_type = 'text';
if ($type == 'num') { $min = '';
if ($type === 'num') {
$input_type = 'number'; $input_type = 'number';
$min = 'min="0"';
} }
if ($with_label) { if ($with_label) {
return sprintf( return sprintf(
'<label %1$s>%5$s<input type="%2$s" name="%3$s" value="%4$s" %5$s></label>', '<label %1$s>%5$s<input type="%2$s" name="%3$s" value="%4$s" %6$s %7$s></label>',
( (
$label_html_classes $label_html_classes
? 'class="' . htmlReady($label_html_classes) . '"' ? 'class="' . htmlReady($label_html_classes) . '"'
...@@ -280,15 +282,17 @@ class ResourcePropertyDefinition extends SimpleORMap ...@@ -280,15 +282,17 @@ class ResourcePropertyDefinition extends SimpleORMap
htmlReady($input_name), htmlReady($input_name),
$value, $value,
htmlReady($this->__toString()), htmlReady($this->__toString()),
$disabled ? 'disabled' : '' $disabled ? 'disabled' : '',
$min
); );
} else { } else {
return sprintf( return sprintf(
'<input type="%1$s" name="%2$s" value="%3$s" %4$s>', '<input type="%1$s" name="%2$s" value="%3$s" %4$s %5$s>',
$input_type, $input_type,
htmlReady($input_name), htmlReady($input_name),
$value, $value,
$disabled ? 'disabled' : '' $disabled ? 'disabled' : '',
$min
); );
} }
} }
......
...@@ -599,6 +599,7 @@ class RoomManager ...@@ -599,6 +599,7 @@ class RoomManager
$result = []; $result = [];
if (!empty($time_ranges)) { if (!empty($time_ranges)) {
//We must check if the room is available: //We must check if the room is available:
foreach ($filtered_rooms as $room) { foreach ($filtered_rooms as $room) {
$room_is_available = $only_fully_available; $room_is_available = $only_fully_available;
...@@ -648,6 +649,9 @@ class RoomManager ...@@ -648,6 +649,9 @@ class RoomManager
if (is_array($properties) && count($properties)) { if (is_array($properties) && count($properties)) {
$old_result = $result; $old_result = $result;
$result = []; $result = [];
$properties = array_filter($properties, function ($property) {
return !empty($property);
});
$required_property_c = count($properties); $required_property_c = count($properties);
foreach ($old_result as $room) { foreach ($old_result as $room) {
$room_property_match = 0; $room_property_match = 0;
...@@ -663,9 +667,9 @@ class RoomManager ...@@ -663,9 +667,9 @@ 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] and $state[1]) { if ($state[0] && $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 ($state[0]) {
...@@ -685,7 +689,7 @@ class RoomManager ...@@ -685,7 +689,7 @@ class RoomManager
} }
} }
} }
if ($room_property_match == $required_property_c) { if ($room_property_match === $required_property_c) {
$result[] = $room; $result[] = $room;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment