Merged from MOODLE_15_STABLE - auth/ldap: Fixed handling of multi-source field mapping. Now fields with non-empty values have precedence over empty fields, regardless of order. Fields will be set to empty only if all ldap source fields are empty.

This commit is contained in:
martinlanghoff 2005-08-25 04:58:59 +00:00
parent 5b66416fe9
commit b8a0a101e5

View File

@ -124,15 +124,19 @@ function auth_get_userinfo($username){
if (!is_array($values)) {
$values = array($values);
}
$ldapval = NULL;
foreach ($values as $value) {
if(is_array($user_entry[0][strtolower($value)])) {
$result[$key]=addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)][0])));
$newval = addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)][0])));
}
else {
$result[$key] = addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)])));
$newval = addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)])));
}
if (!empty($newval)) { // favour ldap entries that are set
$ldapval = $newval;
}
}
$result[$key] = $ldapval;
}
}