From 24c3797dba9fb2ca27f4dd13e15839568f202d90 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 13 Sep 2011 10:36:30 +0000 Subject: [PATCH] * Addressbook/LDAP: fixed country handling for mozillaOrgPerson schema, which has two distinct attributes for 2-letter code and arbitrary name --- .../inc/class.addressbook_ldap.inc.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/addressbook/inc/class.addressbook_ldap.inc.php b/addressbook/inc/class.addressbook_ldap.inc.php index 0124161424..2f27837393 100644 --- a/addressbook/inc/class.addressbook_ldap.inc.php +++ b/addressbook/inc/class.addressbook_ldap.inc.php @@ -137,7 +137,7 @@ class addressbook_ldap // similar to the newer mozillaAbPerson, but uses mozillaPostalAddress2 instead of mozillaStreet2 'mozillaorgperson' => array( 'adr_one_street2' => 'mozillapostaladdress2', - 'adr_one_countryname' => 'c', // 2 letter country code + 'adr_one_countrycode' => 'c', // 2 letter country code 'adr_one_countryname' => 'co', // human readable country name, must be after 'c' to take precedence on read! 'adr_two_street' => 'mozillahomestreet', 'adr_two_street2' => 'mozillahomepostaladdress2', @@ -1144,10 +1144,7 @@ class addressbook_ldap */ function _mozillaorgperson2egw(&$contact,$data) { - if ($data['c'] && strlen($contact['adr_one_countryname']) <= 2) // dont overwrite a set human readable name - { - $contact['adr_one_countryname'] = ExecMethod('phpgwapi.country.get_full_name',$data['c'][0]); - } + // no special handling necessary, as it supports two distinct attributes: c, cn } /** @@ -1162,14 +1159,24 @@ class addressbook_ldap */ function _egw2mozillaorgperson(&$ldapContact,$data,$isUpdate) { - if ($data['adr_one_countryname']) + if ($data['adr_one_countrycode']) + { + $ldapContact['c'] = $data['adr_one_countrycode']; + if ($isUpdate) $ldapContact['co'] = array(); + } + elseif ($data['adr_one_countryname']) { $ldapContact['c'] = ExecMethod('phpgwapi.country.country_code',$data['adr_one_countryname']); + if ($ldapContact['c'] && strlen($ldapContact['c']) > 2) // Bad countryname when "custom" selected! + { + $ldapContact['c'] = array(); // should return error... + } } elseif ($isUpdate) { - $ldapContact['c'] = array(); + $ldapContact['c'] = $ldapContact['co'] = array(); } + //error_log(__METHOD__."() adr_one_countrycode='{$data['adr_one_countrycode']}', adr_one_countryname='{$data['adr_one_countryname']}' --> c=".array2string($ldapContact['c']).', co='.array2string($ldapContact['co'])); } /**