allow an attribute to return more than one value

This commit is contained in:
Arthur Schiwon 2015-10-07 18:57:49 +02:00
parent cd818e7419
commit 4a5cecd6fa
2 changed files with 14 additions and 29 deletions

View File

@ -710,6 +710,9 @@ class Access extends LDAPUtility implements user\IUserTools {
if($manyAttributes) {
return $list;
} else {
$list = array_reduce($list, function($carry, $item) {
$carry[] = $item[0];
}, array());
return array_unique($list, SORT_LOCALE_STRING);
}
}
@ -982,44 +985,26 @@ class Access extends LDAPUtility implements user\IUserTools {
if(!is_null($attr)) {
$selection = array();
$multiArray = false;
if(count($attr) > 1) {
$multiArray = true;
$i = 0;
}
$i = 0;
foreach($findings as $item) {
if(!is_array($item)) {
continue;
}
$item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8');
if($multiArray) {
foreach($attr as $key) {
$key = mb_strtolower($key, 'UTF-8');
if(isset($item[$key])) {
if($key !== 'dn') {
$selection[$i][$key] = $this->resemblesDN($key) ?
$this->sanitizeDN($item[$key][0])
: $item[$key][0];
} else {
$selection[$i][$key] = $this->sanitizeDN($item[$key]);
}
}
}
$i++;
} else {
//tribute to case insensitivity
$key = mb_strtolower($attr[0], 'UTF-8');
foreach($attr as $key) {
$key = mb_strtolower($key, 'UTF-8');
if(isset($item[$key])) {
if($this->resemblesDN($key)) {
$selection[] = $this->sanitizeDN($item[$key]);
if($key !== 'dn') {
$selection[$i][$key] = $this->resemblesDN($key) ?
$this->sanitizeDN($item[$key])
: $item[$key];
} else {
$selection[] = $item[$key];
$selection[$i][$key] = $this->sanitizeDN($item[$key]);
}
}
}
$i++;
}
$findings = $selection;
}

View File

@ -435,7 +435,7 @@ class Wizard extends LDAPUtility {
// detection will fail later
$result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset);
foreach($result as $item) {
$groupNames[] = $item['cn'];
$groupNames[] = $item['cn'][0];
$groupEntries[] = $item;
}
$offset += $limit;