Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Open
LU Contacts
Commits
df0678c9
Commit
df0678c9
authored
Sep 13, 2021
by
Dainis Abols
Browse files
Fixed multiple departments bug
v3.3.2
parent
f74940f7
Changes
4
Show whitespace changes
Inline
Side-by-side
Classes/Models/Person.php
View file @
df0678c9
...
...
@@ -11,7 +11,6 @@ use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 3.0.0
* @since 29.06.2018
*
* @package Lu\LuContacts\Models
...
...
@@ -110,7 +109,7 @@ class Person
// Add position and phone info
if
(
$item
[
'_childDocuments_'
])
{
$k
=
0
;
$k
=
0
;
foreach
(
$item
[
'_childDocuments_'
]
as
$children
)
{
$k
++
;
...
...
@@ -119,9 +118,8 @@ class Person
$tmp
[
'position'
][
$k
]
=
$children
[
'name'
];
}
// dd($children);
if
(
$children
[
'unit_ids'
])
{
foreach
(
$children
[
'unit_ids'
]
as
$keyUnitId
)
{
foreach
(
$children
[
'unit_ids'
]
as
$keyUnitId
)
{
if
(
key_exists
(
$keyUnitId
,
$tmp
[
'unitNames'
])
&&
!
key_exists
(
$keyUnitId
,
$tmp
[
'unit'
]))
{
$tmp
[
'unit'
][
$k
][]
=
$tmp
[
'unitNames'
][
$keyUnitId
];
}
...
...
@@ -134,9 +132,6 @@ class Person
$tmp
[
'phone'
][
$k
]
=
$this
->
implode
(
$children
[
'phone'
]);
}
}
// Reverse workplace position results [Why was this needed?? [Dainis]]
// $tmp['position'] = array_reverse($tmp['position']);
}
$tmp
[
'unit'
]
=
$this
->
implode
(
$tmp
[
'unit'
]);
...
...
@@ -353,15 +348,20 @@ class Person
}
// Fetch unit IDs foe person
foreach
(
$details
[
'unit_ids'
]
as
$userUnitId
)
{
foreach
(
$details
[
'unit_ids'
]
as
$userUnitId
)
{
if
(
$recursive
)
{
$UnitModel
=
new
Unit
();
$userUnits
=
array_reverse
(
$UnitModel
->
getRecursiveUnitIds
(
$userUnitId
));
$userUnits
[]
=
array_reverse
(
$UnitModel
->
getRecursiveUnitIds
(
$userUnitId
));
}
else
{
$userUnits
[]
=
$userUnitId
;
}
}
// Flatten into onel evel array
if
(
!
empty
(
$userUnits
))
{
$userUnits
=
$this
->
array_flatten
(
$userUnits
);
}
// Return result
return
in_array
(
$unitId
,
$userUnits
);
}
...
...
@@ -377,4 +377,30 @@ class Person
{
return
'<img src="'
.
$image
.
'" />'
;
}
/**
* Flattens array.
*
* @param array $array
*
* @return array
*/
private
function
array_flatten
(
array
$array
)
{
$flat
=
[];
// initialize return array
$stack
=
array_values
(
$array
);
// initialize stack
while
(
$stack
)
// process stack until done
{
$value
=
array_shift
(
$stack
);
if
(
is_array
(
$value
))
// a value to further process
{
array_unshift
(
$stack
,
...
$value
);
}
else
// a value to take
{
$flat
[]
=
$value
;
}
}
return
$flat
;
}
}
composer.json
View file @
df0678c9
{
"name"
:
"luitd/lu-contacts"
,
"version"
:
"3.3.
1
"
,
"version"
:
"3.3.
2
"
,
"description"
:
"University of Latvia contact list render"
,
"type"
:
"typo3-cms-extension"
,
"keywords"
:
[
...
...
ext_emconf.php
View file @
df0678c9
...
...
@@ -9,7 +9,7 @@ $EM_CONF[$_EXTKEY] = [
'author_email'
=>
'dainis.abols@lu.lv'
,
'state'
=>
'stable'
,
'clearCacheOnLoad'
=>
true
,
'version'
=>
'3.3.
1
'
,
'version'
=>
'3.3.
2
'
,
'dependencies'
=>
'typo3,lu_api'
,
'constraints'
=>
[
'depends'
=>
[
...
...
readme.md
View file @
df0678c9
...
...
@@ -4,7 +4,7 @@ Extension to render list of contacts for University of Latvia
## Version
3.
3.
1
3.
3.
2
## Dependencies
...
...
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