Skip to content

Commit

Permalink
use correct key of $attributes_map for sorting LDAP multivalued attri…
Browse files Browse the repository at this point in the history
…butes (#171)
  • Loading branch information
David Coutadeur authored and davidcoutadeur committed Nov 18, 2024
1 parent 74cad0b commit 5d38e70
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions htdocs/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,29 @@
# Sort attributes values
foreach ($entry[0] as $attr => $values) {
if ( is_array($values) && $values['count'] > 1 ) {
if(isset($attributes_map[$attr]['sort']))

# Find key in attributes_map
$attributes_map_filter = array_filter($attributes_map, function($v) use(&$attr) {
return $v['attribute'] == "$attr";
});
if( count($attributes_map_filter) < 1 )
{
$k = "";
error_log("WARN: no key found for attribute $attr in \$attributes_map");
}
elseif( count($attributes_map_filter) > 1 )
{
$k = array_key_first($attributes_map_filter);
error_log("WARN: multiple keys found for attribute $attr in \$attributes_map, using first one: $k");
}
else
{
$k = array_key_first($attributes_map_filter);
}

if(isset($attributes_map[$k]['sort']))
{
if($attributes_map[$attr]['sort'] == "descending" )
if($attributes_map[$k]['sort'] == "descending" )
{
# descending sort
arsort($values);
Expand Down

0 comments on commit 5d38e70

Please sign in to comment.