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
$this->room_name = $_SESSION[$request_id]['room_name'];
$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'] ?? [];
......@@ -340,7 +340,6 @@ class Course_RoomRequestsController extends AuthenticatedController
if (Request::submitted('search_rooms')) {
$this->selected_properties = Request::getArray('selected_properties');
$_SESSION[$request_id]['selected_properties'] = $this->selected_properties;
// no min number of seats
if (
(!$_SESSION[$request_id]['selected_properties']['seats'] || $_SESSION[$request_id]['selected_properties']['seats'] < 1)
......@@ -408,7 +407,7 @@ class Course_RoomRequestsController extends AuthenticatedController
$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->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->selected_properties['seats'] = $_SESSION[$request_id]['selected_properties']['seats']
......@@ -530,8 +529,10 @@ class Course_RoomRequestsController extends AuthenticatedController
$this->redirect('course/room_requests/request_show_summary/' . $this->request_id );
} else {
$room = Room::find($_SESSION[$request_id]['room_id']);
$this->step = 2;
$this->request = new RoomRequest($this->request_id);
$_SESSION[$request_id]['room_category_id'] = $room->category_id;
$this->redirect(
'course/room_requests/request_find_matching_rooms/' . $this->request_id . '/' . $this->step
);
......
......@@ -226,9 +226,9 @@
<? if (Request::isXhr() && !$locked && Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS): ?>
<? ?>
<?= 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(
'course/room_requests/request_show_summary/' . $request_id
)
......
......@@ -154,7 +154,7 @@ class ResourcePropertyDefinition extends SimpleORMap
? $special_name
: 'properties[' . $this->id . ']';
if ($type == 'bool') {
if ($type === 'bool') {
$label_html_classes = 'col-3';
//Booleans can have one or two input elements,
//whether a false state shall be selectable or not.
......@@ -188,7 +188,7 @@ class ResourcePropertyDefinition extends SimpleORMap
} else {
return $input_html;
}
} elseif ($type == 'select') {
} elseif ($type === 'select') {
$options_html = sprintf(
'<option value="" %2$s>%1$s</option>',
_('Bitte wählen'),
......@@ -220,7 +220,7 @@ class ResourcePropertyDefinition extends SimpleORMap
$options_html
);
}
} elseif ($type == 'position') {
} elseif ($type === 'position') {
$factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH']);
$template = $factory->open('templates/resources/position_attribute_form_part.php');
$template->set_attribute(
......@@ -241,7 +241,7 @@ class ResourcePropertyDefinition extends SimpleORMap
);
return $template->render();
} elseif ($type == 'user') {
} elseif ($type === 'user') {
$search = new QuickSearch($input_name, new StandardSearch('user_id'));
$search->defaultValue($value, ($value ? get_fullname($value, 'full_rev_username') : ''));
return sprintf(
......@@ -265,12 +265,14 @@ class ResourcePropertyDefinition extends SimpleORMap
);
} else {
$input_type = 'text';
if ($type == 'num') {
$min = '';
if ($type === 'num') {
$input_type = 'number';
$min = 'min="0"';
}
if ($with_label) {
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
? 'class="' . htmlReady($label_html_classes) . '"'
......@@ -280,15 +282,17 @@ class ResourcePropertyDefinition extends SimpleORMap
htmlReady($input_name),
$value,
htmlReady($this->__toString()),
$disabled ? 'disabled' : ''
$disabled ? 'disabled' : '',
$min
);
} else {
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,
htmlReady($input_name),
$value,
$disabled ? 'disabled' : ''
$disabled ? 'disabled' : '',
$min
);
}
}
......
......@@ -599,6 +599,7 @@ class RoomManager
$result = [];
if (!empty($time_ranges)) {
//We must check if the room is available:
foreach ($filtered_rooms as $room) {
$room_is_available = $only_fully_available;
......@@ -648,6 +649,9 @@ class RoomManager
if (is_array($properties) && count($properties)) {
$old_result = $result;
$result = [];
$properties = array_filter($properties, function ($property) {
return !empty($property);
});
$required_property_c = count($properties);
foreach ($old_result as $room) {
$room_property_match = 0;
......@@ -663,9 +667,9 @@ class RoomManager
//Furthermore we must check if only minimum or maximum are
//set or if both are set. Depending on that condition,
//the conditions are different.
if ($state[0] and $state[1]) {
if ($state[0] && $state[1]) {
//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++;
}
} elseif ($state[0]) {
......@@ -685,7 +689,7 @@ class RoomManager
}
}
}
if ($room_property_match == $required_property_c) {
if ($room_property_match === $required_property_c) {
$result[] = $room;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment