Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
187f03c4
Commit
187f03c4
authored
11 months ago
by
David Siegfried
Committed by
Jan-Hendrik Willms
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fixes #4000
Closes #4000 Merge request
studip/studip!2849
parent
033892bb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/course/room_requests.php
+37
-64
37 additions, 64 deletions
app/controllers/course/room_requests.php
with
37 additions
and
64 deletions
app/controllers/course/room_requests.php
+
37
−
64
View file @
187f03c4
...
@@ -143,25 +143,15 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -143,25 +143,15 @@ class Course_RoomRequestsController extends AuthenticatedController
// a single date or whole course
// a single date or whole course
$this
->
request_range_id
=
Request
::
get
(
'range_id'
,
Context
::
getId
());
$this
->
request_range_id
=
Request
::
get
(
'range_id'
,
Context
::
getId
());
if
(
!
isset
(
$_SESSION
[
$this
->
request_id
]))
{
$this
->
init_session
();
$_SESSION
[
$this
->
request_id
]
=
[];
}
$_SESSION
[
$this
->
request_id
][
'range'
]
=
$this
->
request_range
?:
$_SESSION
[
$this
->
request_id
][
'range'
]
??
null
;
$_SESSION
[
$this
->
request_id
][
'range'
]
=
$this
->
request_range
?:
$_SESSION
[
$this
->
request_id
][
'range'
]
??
null
;
$_SESSION
[
$this
->
request_id
][
'range_ids'
]
=
$this
->
request_range_ids
?:
[
$this
->
request_range_id
];
$_SESSION
[
$this
->
request_id
][
'range_ids'
]
=
$this
->
request_range_ids
?:
[
$this
->
request_range_id
];
$_SESSION
[
$this
->
request_id
][
'search_by'
]
=
''
;
$_SESSION
[
$this
->
request_id
][
'room_category_id'
]
=
''
;
$_SESSION
[
$this
->
request_id
][
'room_id'
]
=
''
;
$_SESSION
[
$this
->
request_id
][
'room_name'
]
=
''
;
$_SESSION
[
$this
->
request_id
][
'selected_properties'
]
=
[];
$this
->
request
=
null
;
// look for existing request or create a new one
// look for existing request or create a new one
$this
->
request
=
new
RoomRequest
(
$this
->
request_id
);
$this
->
request
=
new
RoomRequest
(
$this
->
request_id
);
// time ranges (start date, end date)
// time ranges (start date, end date)
$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'
]);
$this
->
request_time_intervals
=
$this
->
request
->
getTimeIntervals
();
$this
->
request_time_intervals
=
$this
->
request
->
getTimeIntervals
();
}
}
/**
/**
...
@@ -211,7 +201,6 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -211,7 +201,6 @@ class Course_RoomRequestsController extends AuthenticatedController
);
);
}
}
}
}
}
}
/**
/**
...
@@ -227,7 +216,6 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -227,7 +216,6 @@ class Course_RoomRequestsController extends AuthenticatedController
_
(
'Das Erstellen von Raumanfragen ist nicht erlaubt!'
)
_
(
'Das Erstellen von Raumanfragen ist nicht erlaubt!'
)
);
);
}
}
$this
->
request_id
=
$request_id
;
$this
->
request_id
=
$request_id
;
$this
->
step
=
(
int
)
$step
;
$this
->
step
=
(
int
)
$step
;
$this
->
room_name
=
$_SESSION
[
$request_id
][
'room_name'
];
$this
->
room_name
=
$_SESSION
[
$request_id
][
'room_name'
];
...
@@ -266,13 +254,16 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -266,13 +254,16 @@ 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
->
selected_room_category_id
=
$this
->
selected_room
->
category_id
??
$_SESSION
[
$request_id
][
'room_category_id'
]
??
null
;
$this
->
selected_room_category_id
=
$this
->
selected_room
->
category_id
??
$_SESSION
[
$request_id
][
'room_category_id'
]
??
null
;
$this
->
category
=
ResourceCategory
::
find
(
$this
->
selected_room_category_id
);
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$_SESSION
[
$request_id
][
'room_category_id'
]
??
$this
->
selected_room
->
category_id
??
null
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$_SESSION
[
$request_id
][
'room_category_id'
]
??
$this
->
selected_room
->
category_id
??
null
;
// after selecting a room, go to next step or stay here if no room was selected at all
// after selecting a room, go to next step or stay here if no room was selected at all
if
(
Request
::
submitted
(
'select_room'
))
{
if
(
Request
::
submitted
(
'select_room'
))
{
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$room
=
Room
::
find
(
$this
->
selected_room_id
);
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$room
->
category_id
;
$_SESSION
[
$request_id
][
'select_room'
]
=
true
;
$_SESSION
[
$request_id
][
'select_room'
]
=
true
;
$this
->
redirect
(
$this
->
redirect
(
'course/room_requests/request_check_properties/'
.
$this
->
request_id
'course/room_requests/request_check_properties/'
.
$this
->
request_id
...
@@ -296,48 +287,20 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -296,48 +287,20 @@ class Course_RoomRequestsController extends AuthenticatedController
);
);
return
;
return
;
}
else
if
(
Request
::
submitted
(
'reset_category'
))
{
}
else
if
(
Request
::
submitted
(
'reset_category'
))
{
//Delete all selected properties from the session since the category is reset
$this
->
init_session
();
$_SESSION
[
$request_id
][
'selected_properties'
]
=
[];
$this
->
redirect
(
'course/room_requests/new_request'
);
$_SESSION
[
$request_id
][
'room_category_id'
]
=
''
;
$_SESSION
[
$request_id
][
'room_name'
]
=
''
;
$_SESSION
[
$request_id
][
'room_id'
]
=
''
;
$this
->
redirect
(
'course/room_requests/request_find_available_properties/'
.
$this
->
request_id
.
'/1'
);
return
;
return
;
}
}
// for step 2: after choosing a specific room OR searching via properties
// for step 2: after choosing a specific room OR searching via properties
if
(
$this
->
step
===
2
)
{
if
(
$this
->
step
===
2
)
{
// find rooms fitting to category and properties
if
(
!
empty
(
Request
::
getArray
(
'selected_properties'
)))
{
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
;
}
else
{
// no min number of seats
$this
->
selected_properties
=
$_SESSION
[
$request_id
][
'selected_properties'
];
if
(
(
!
isset
(
$_SESSION
[
$request_id
][
'selected_properties'
][
'seats'
])
||
$_SESSION
[
$request_id
][
'selected_properties'
][
'seats'
]
<
1
)
&&
$_SESSION
[
$request_id
][
'search_by'
]
===
'category'
)
{
PageLayout
::
postError
(
_
(
'Die Mindestanzahl der Sitzplätze beträgt 1!'
)
);
$this
->
redirect
(
'course/room_requests/request_find_matching_rooms/'
.
$request_id
.
'/'
.
$this
->
step
);
return
;
}
else
{
$this
->
redirect
(
'course/room_requests/request_find_matching_rooms/'
.
$request_id
.
'/'
.
$this
->
step
);
return
;
}
}
}
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
if
(
$_SESSION
[
$request_id
][
'search_by'
]
===
'roomname'
)
{
if
(
$_SESSION
[
$request_id
][
'search_by'
]
===
'roomname'
)
{
// find category via room
$this
->
category
=
ResourceCategory
::
find
(
$this
->
selected_room_category_id
);
if
(
$this
->
category
)
{
$this
->
available_properties
=
$this
->
category
->
getRequestableProperties
();
}
$this
->
selected_properties
=
$_SESSION
[
$request_id
][
'selected_properties'
]
??
null
;
$this
->
selected_properties
=
$_SESSION
[
$request_id
][
'selected_properties'
]
??
null
;
$this
->
room
=
Room
::
find
(
$_SESSION
[
$request_id
][
'room_id'
]);
$this
->
room
=
Room
::
find
(
$_SESSION
[
$request_id
][
'room_id'
]);
if
(
!
isset
(
$_SESSION
[
$request_id
][
'selected_properties'
][
'seats'
]))
{
if
(
!
isset
(
$_SESSION
[
$request_id
][
'selected_properties'
][
'seats'
]))
{
...
@@ -359,14 +322,11 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -359,14 +322,11 @@ class Course_RoomRequestsController extends AuthenticatedController
}
else
{
}
else
{
// let's find all the properties belonging to the selected category
// let's find all the properties belonging to the selected category
$this
->
room_category_id
=
$_SESSION
[
$request_id
][
'room_category_id'
];
$this
->
room_category_id
=
$_SESSION
[
$request_id
][
'room_category_id'
];
$this
->
category
=
ResourceCategory
::
find
(
$this
->
room_category_id
);
if
(
$this
->
category
)
{
$this
->
available_properties
=
$this
->
category
->
getRequestableProperties
();
}
// properties, like 'Sitzplätze', 'behindertengerecht' etc
$this
->
selected_properties
=
$_SESSION
[
$request_id
][
'selected_properties'
]
??
null
;
}
}
if
(
$this
->
category
)
{
$this
->
available_properties
=
$this
->
category
->
getRequestableProperties
();
}
$this
->
preparation_time
=
$_SESSION
[
$request_id
][
'preparation_time'
]
??
null
;
$this
->
preparation_time
=
$_SESSION
[
$request_id
][
'preparation_time'
]
??
null
;
$this
->
comment
=
$_SESSION
[
$request_id
][
'comment'
]
??
null
;
$this
->
comment
=
$_SESSION
[
$request_id
][
'comment'
]
??
null
;
$this
->
request
->
category_id
=
$_SESSION
[
$request_id
][
'room_category_id'
];
$this
->
request
->
category_id
=
$_SESSION
[
$request_id
][
'room_category_id'
];
...
@@ -375,8 +335,10 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -375,8 +335,10 @@ class Course_RoomRequestsController extends AuthenticatedController
if
(
Request
::
submitted
(
'show_summary'
))
{
if
(
Request
::
submitted
(
'show_summary'
))
{
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'selected_properties'
]
=
Request
::
getArray
(
'selected_properties'
);
$room
=
Room
::
find
(
$this
->
selected_room_id
);
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$this
->
category
->
id
;
if
(
$room
)
{
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$room
->
category_id
;
}
$this
->
redirect
(
'course/room_requests/request_show_summary/'
.
$this
->
request_id
);
$this
->
redirect
(
'course/room_requests/request_show_summary/'
.
$this
->
request_id
);
}
}
}
}
...
@@ -395,7 +357,6 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -395,7 +357,6 @@ class Course_RoomRequestsController extends AuthenticatedController
_
(
'Das Erstellen von Raumanfragen ist nicht erlaubt!'
)
_
(
'Das Erstellen von Raumanfragen ist nicht erlaubt!'
)
);
);
}
}
$this
->
request_id
=
$request_id
;
$this
->
request_id
=
$request_id
;
$this
->
step
=
(
int
)
$step
;
$this
->
step
=
(
int
)
$step
;
...
@@ -456,11 +417,13 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -456,11 +417,13 @@ class Course_RoomRequestsController extends AuthenticatedController
}
}
$this
->
request_id
=
$request_id
;
$this
->
request_id
=
$request_id
;
$this
->
selected_properties
=
Request
::
getArray
(
'selected_properties'
);
// select a room, search for a room name or search for rooms matching properties
// select a room, search for a room name or search for rooms matching properties
if
(
Request
::
submitted
(
'select_room'
))
{
if
(
Request
::
submitted
(
'select_room'
))
{
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$room
=
Room
::
find
(
$this
->
selected_room_id
);
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$room
->
category_id
;
$_SESSION
[
$request_id
][
'select_room'
]
=
true
;
$_SESSION
[
$request_id
][
'select_room'
]
=
true
;
$this
->
step
=
2
;
$this
->
step
=
2
;
$this
->
request
=
new
RoomRequest
(
$this
->
request_id
);
$this
->
request
=
new
RoomRequest
(
$this
->
request_id
);
...
@@ -468,7 +431,6 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -468,7 +431,6 @@ class Course_RoomRequestsController extends AuthenticatedController
'course/room_requests/request_find_matching_rooms/'
.
$this
->
request_id
.
'/'
.
$this
->
step
'course/room_requests/request_find_matching_rooms/'
.
$this
->
request_id
.
'/'
.
$this
->
step
);
);
}
else
if
(
Request
::
get
(
'room_name'
)
&&
Request
::
submitted
(
'search_by_name'
))
{
}
else
if
(
Request
::
get
(
'room_name'
)
&&
Request
::
submitted
(
'search_by_name'
))
{
$this
->
selected_properties
=
Request
::
getArray
(
'selected_properties'
);
$this
->
category_id
=
Request
::
get
(
'category_id'
);
$this
->
category_id
=
Request
::
get
(
'category_id'
);
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$this
->
category_id
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$this
->
category_id
;
...
@@ -480,7 +442,6 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -480,7 +442,6 @@ class Course_RoomRequestsController extends AuthenticatedController
);
);
}
else
if
(
Request
::
submitted
(
'search_rooms'
))
{
}
else
if
(
Request
::
submitted
(
'search_rooms'
))
{
$this
->
selected_properties
=
Request
::
getArray
(
'selected_properties'
);
$this
->
category_id
=
Request
::
get
(
'category_id'
);
$this
->
category_id
=
Request
::
get
(
'category_id'
);
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$this
->
category_id
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$this
->
category_id
;
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
...
@@ -507,8 +468,7 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -507,8 +468,7 @@ class Course_RoomRequestsController extends AuthenticatedController
}
}
}
else
if
(
Request
::
submitted
(
'reset_category'
))
{
}
else
if
(
Request
::
submitted
(
'reset_category'
))
{
//Delete all selected properties from the session since the category is reset
//Delete all selected properties from the session since the category is reset
$_SESSION
[
$request_id
][
'selected_properties'
]
=
[];
$this
->
init_session
();
$_SESSION
[
$request_id
][
'room_category_id'
]
=
''
;
$this
->
redirect
(
'course/room_requests/request_find_available_properties/'
.
$this
->
request_id
.
'/1'
);
$this
->
redirect
(
'course/room_requests/request_find_available_properties/'
.
$this
->
request_id
.
'/1'
);
}
else
if
(
Request
::
submitted
(
'search_by_category'
))
{
}
else
if
(
Request
::
submitted
(
'search_by_category'
))
{
if
(
Request
::
get
(
'category_id'
)
===
'0'
)
{
if
(
Request
::
get
(
'category_id'
)
===
'0'
)
{
...
@@ -522,11 +482,10 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -522,11 +482,10 @@ class Course_RoomRequestsController extends AuthenticatedController
);
);
}
else
if
(
Request
::
submitted
(
'show_summary'
))
{
}
else
if
(
Request
::
submitted
(
'show_summary'
))
{
$this
->
request
=
new
RoomRequest
(
$this
->
request_id
);
$this
->
request
=
new
RoomRequest
(
$this
->
request_id
);
$this
->
selected_properties
=
Request
::
getArray
(
'selected_properties'
);
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$this
->
selected_room_id
=
Request
::
get
(
'selected_room_id'
);
$room
=
Room
::
find
(
$this
->
selected_room_id
);
$room
=
Room
::
find
(
$this
->
selected_room_id
);
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_id'
]
=
$this
->
selected_room_id
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$room
->
category_id
;
$_SESSION
[
$request_id
][
'room_category_id'
]
=
$room
->
category_id
??
$_SESSION
[
$request_id
][
'room_category_id'
]
;
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
$_SESSION
[
$request_id
][
'selected_properties'
]
=
$this
->
selected_properties
;
$this
->
redirect
(
'course/room_requests/request_show_summary/'
.
$this
->
request_id
);
$this
->
redirect
(
'course/room_requests/request_show_summary/'
.
$this
->
request_id
);
}
else
{
}
else
{
...
@@ -570,7 +529,6 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -570,7 +529,6 @@ class Course_RoomRequestsController extends AuthenticatedController
);
);
$this
->
selected_room_category
=
ResourceCategory
::
find
(
$_SESSION
[
$request_id
][
'room_category_id'
]
??
$this
->
request
->
category_id
);
$this
->
selected_room_category
=
ResourceCategory
::
find
(
$_SESSION
[
$request_id
][
'room_category_id'
]
??
$this
->
request
->
category_id
);
$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
->
room_id
=
$_SESSION
[
$request_id
][
'room_id'
]
??
$this
->
request
->
resource_id
;
$this
->
room_id
=
$_SESSION
[
$request_id
][
'room_id'
]
??
$this
->
request
->
resource_id
;
...
@@ -726,4 +684,19 @@ class Course_RoomRequestsController extends AuthenticatedController
...
@@ -726,4 +684,19 @@ class Course_RoomRequestsController extends AuthenticatedController
}
}
$this
->
redirect
(
'course/timesrooms/index'
);
$this
->
redirect
(
'course/timesrooms/index'
);
}
}
private
function
init_session
()
{
$_SESSION
[
$this
->
request_id
]
=
array_merge
(
$_SESSION
[
$this
->
request_id
]
??
[],
[
'search_by'
=>
''
,
'room_category_id'
=>
''
,
'room_id'
=>
''
,
'room_name'
=>
''
,
'select_room'
=>
false
,
'selected_properties'
=>
[],
]
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment