Don't attempt to get the country name from NLS if we don't have a country entry.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 17 Sep 2010 18:01:47 +0000 (14:01 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 17 Sep 2010 18:03:49 +0000 (14:03 -0400)
Horde_Nls::getCountryISO() returns the full array of country codes -> names if an empty
value is passed to it. Also, fix hash key for homeCountry when deleting it from PIM -> Server

turba/lib/Driver.php

index e24ae2d..24968ac 100644 (file)
@@ -2333,7 +2333,7 @@ class Turba_Driver implements Countable
                 break;
 
             case 'homeCountry':
-                $message->homecountry = Horde_String::convertCharset(Horde_Nls::getCountryISO($hash['homeCountry']), $charset, 'utf-8');
+                $message->homecountry = !empty($hash['homeCountry']) ? Horde_String::convertCharset(Horde_Nls::getCountryISO($hash['homeCountry']), $charset, 'utf-8') : null;
                 break;
 
             case 'workStreet':
@@ -2353,7 +2353,7 @@ class Turba_Driver implements Countable
                 break;
 
             case 'workCountry':
-                $message->businesscountry = Horde_String::convertCharset(Horde_Nls::getCountryISO($hash['workCountry']), $charset, 'utf-8');
+                $message->businesscountry = !empty($hash['workCountry']) ? Horde_String::convertCharset(Horde_Nls::getCountryISO($hash['workCountry']), $charset, 'utf-8') : null;
 
             case 'homePhone':
                 /* Phone */
@@ -2527,7 +2527,7 @@ class Turba_Driver implements Countable
                 $country = Horde_String::convertCharset($message->homecountry, 'utf-8', $charset);
             }
             $hash['homeCountry'] = $country;
-        } elseif (!$message->isGhosted('businesscountry')) {
+        } elseif (!$message->isGhosted('homecountry')) {
             $hash['homeCountry'] = null;
         }