From 08ff640a899e24b87ad0eb48e6dcada817155d48 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 11 May 2010 11:33:12 -0400 Subject: [PATCH] Fix country handling for AS. Use the localized name of the country when sending to the device, and assume the value coming from the device is also the localized name. --- turba/lib/Driver.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index 982598ce4..8547bf70a 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -2340,7 +2340,7 @@ class Turba_Driver $message->homepostalcode = Horde_String::convertCharset($hash['homePostalCode'], $charset, 'utf-8'); break; case 'homeCountry': - $message->homecountry = Horde_String::convertCharset($hash['homeCountry'], $charset, 'utf-8'); + $message->homecountry = Horde_String::convertCharset(self::getCountry($hash['homeCountry']), $charset, 'utf-8'); break; case 'workStreet': $message->businessstreet = Horde_String::convertCharset($hash['workStreet'], $charset, 'utf-8'); @@ -2450,12 +2450,10 @@ class Turba_Driver 'homecity' => 'homeCity', 'homestate' => 'homeProvince', 'homepostalcode' => 'homePostalCode', - 'homecountry' => 'homeCountry', 'businessstreet' => 'workStreet', 'businesscity' => 'workCity', 'businessstate' => 'workProvince', 'businesspostalcode' => 'workPostalCode', - 'businesscountry' => 'workCountry', 'jobtitle' => 'title', 'companyname' => 'company', 'department' => 'department', @@ -2517,6 +2515,19 @@ class Turba_Driver $hash['anniversary'] = null; } + /* Countries */ + include 'Horde/Nls/Countries.php'; + $country = array_search($message->homecountry, $countries); + if ($country === false) { + $country = Horde_String::convertCharset($message->homecountry, 'utf-8', $charset); + } + $hash['homeCountry'] = $country; + $country = array_search($message->businesscountry, $countries); + if ($country === false) { + $country = Horde_String::convertCharset($message->businesscountry, 'utf-8', $charset); + } + $hash['workCountry'] = $country; + return $hash; } -- 2.11.0