mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
* CardDAV/Addressbook/LDAP/ADS: prefix, middle name, suffix was messed up, if iOS addressbook "Display Order" preferences was set to "lastname firstname"
This commit is contained in:
parent
ab3ac17367
commit
aa4af55f5f
@ -1235,15 +1235,17 @@ class addressbook_ldap
|
||||
$contact['n_prefix'] = trim($parts[0]);
|
||||
$contact['n_suffix'] = trim($parts[1]);
|
||||
}
|
||||
// iOS addressbook either use "givenname surname" or "surname givenname" depending on contact preference display-order
|
||||
// in full name, so we need to check for both when trying to parse prefix, middle name and suffix form full name
|
||||
elseif (preg_match($preg='/^(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*) *'.preg_quote($data['sn'][0], '/').' *(.*)$/', $data[$cn][0], $matches) ||
|
||||
preg_match($preg='/^(.*) *'.preg_quote($data['sn'][0], '/').'[, ]*(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*)$/', $data[$cn][0], $matches))
|
||||
{
|
||||
list(,$contact['n_prefix'], $contact['n_middle'], $contact['n_suffix']) = $matches;
|
||||
//error_log(__METHOD__."() preg_match('$preg', '{$data[$cn][0]}') = ".array2string($matches));
|
||||
}
|
||||
else
|
||||
{
|
||||
$parts = preg_split('/'. preg_quote($data['givenname'][0],'/') .'.*'. preg_quote($data['sn'][0],'/') .'/', $data[$cn][0]);
|
||||
$contact['n_prefix'] = trim($parts[0]);
|
||||
$contact['n_suffix'] = trim($parts[1]);
|
||||
if(preg_match('/'. preg_quote($data['givenname'][0],'/') .' (.*) '. preg_quote($data['sn'][0],'/') .'/',$data[$cn][0], $matches))
|
||||
{
|
||||
$contact['n_middle'] = $matches[1];
|
||||
}
|
||||
$contact['n_prefix'] = $contact['n_suffix'] = $contact['n_middle'] = '';
|
||||
}
|
||||
//error_log(__METHOD__."(, data=array($cn=>{$data[$cn][0]}, sn=>{$data['sn'][0]}, givenName=>{$data['givenname'][0]}), cn='$cn') returning with contact=array(n_prefix={$contact['n_prefix']}, n_middle={$contact['n_middle']}, n_suffix={$contact['n_suffix']}) ".function_backtrace());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user