Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
AStA
Raumbuchungstool
Commits
4711d3ed
Commit
4711d3ed
authored
Oct 19, 2020
by
Michael Koch
Browse files
Apparently, this is how you do deep array merges without duplicates.
parent
e05feb74
Changes
1
Hide whitespace changes
Inline
Side-by-side
php/reservations.php
View file @
4711d3ed
...
...
@@ -446,7 +446,7 @@ function addReservation($q) {
"to_event_before"
=>
$q
->
to_event
,
"rooms"
=>
array
(
$q
->
room_id
)
);
$existing_reservations
=
array_
unique
(
array_merge
(
$existing_reservations
,
getReservationsFiltered
(
json_decode
(
json_encode
(
$resv_options
),
false
),
true
)));
$existing_reservations
=
array_
map
(
"unserialize"
,
array_unique
(
array_map
(
"serialize"
,
array_merge
(
$existing_reservations
,
getReservationsFiltered
(
json_decode
(
json_encode
(
$resv_options
),
false
),
true
)))
)
;
if
(
sizeof
(
$existing_reservations
)
>
0
)
{
fail
(
"Timeslot already booked"
);
...
...
@@ -479,7 +479,7 @@ function addReservation($q) {
"rooms"
=>
array
(
$q
->
room_id
),
"confirmed"
=>
1
);
$existing_reservations
=
array_
unique
(
array_merge
(
$existing_reservations
,
getReservationsFiltered
(
json_decode
(
json_encode
(
$resv_options
),
false
),
true
)));
$existing_reservations
=
array_
map
(
"unserialize"
,
array_unique
(
array_map
(
"serialize"
,
array_merge
(
$existing_reservations
,
getReservationsFiltered
(
json_decode
(
json_encode
(
$resv_options
),
false
),
true
)))
)
;
if
(
sizeof
(
$existing_reservations
)
>
11
)
{
fail
(
"Studyspace overbooked"
);
...
...
Leon Tappe
🔥
@ltappe
·
Oct 20, 2020
Owner
praise the php lord for giving us such a easy way
🙏
🙏
🙏
Edited
Oct 20, 2020
by
Leon Tappe
praise the php lord for giving us such a easy way 🙏🙏🙏
😆
1
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment