Skip to content

Commit

Permalink
LDAP : add option to get data as an array
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Kohlhaas committed Feb 25, 2013
1 parent cfa1a41 commit 428f844
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions htdocs/core/class/ldap.class.php
Expand Up @@ -874,9 +874,10 @@ function getAttributeValues($filterrecord,$attribute)
* @param string $useridentifier Name of key field (Ex: uid)
* @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword)
* @param int $activefilter 1=use field this->filter as filter instead of parameter $search
* @param array $attributeAsArray Array of fields wanted as an array not a string
* @return array Array of [id_record][ldap_field]=value
*/
function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0)
function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter=0, $attributeAsArray=array())
{
$fulllist=array();

Expand Down Expand Up @@ -955,7 +956,15 @@ function getRecords($search, $userDn, $useridentifier, $attributeArray, $activef
}
else
{
$fulllist[$recordid][$attributeArray[$j]] = $this->convToOutputCharset($info[$i][$keyattributelower][0],$this->ldapcharset);
if(in_array($attributeArray[$j], $attributeAsArray) && is_array($info[$i][$keyattributelower])) {
$valueTab = array();
foreach($info[$i][$keyattributelower] as $key => $value) {
$valueTab[$key] = $this->convToOutputCharset($value,$this->ldapcharset);
}
$fulllist[$recordid][$attributeArray[$j]] = $valueTab;
} else {
$fulllist[$recordid][$attributeArray[$j]] = $this->convToOutputCharset($info[$i][$keyattributelower][0],$this->ldapcharset);
}
}
}
}
Expand Down

0 comments on commit 428f844

Please sign in to comment.