Update deleted attributes during synchronization (lst_hoe02@kwsoft.de, Request #6658).
authorJan Schneider <jan@horde.org>
Thu, 1 Oct 2009 12:00:55 +0000 (14:00 +0200)
committerJan Schneider <jan@horde.org>
Thu, 1 Oct 2009 12:00:55 +0000 (14:00 +0200)
turba/docs/CHANGES
turba/lib/Driver.php

index 309b11c..dd61ca7 100644 (file)
@@ -10,6 +10,8 @@ v3.0-git
 v2.3.3-cvs
 ----------
 
+[jan] Update deleted attributes during synchronization (lst_hoe02@kwsoft.de,
+      Request #6658).
 [jan] Support X-ANNIVERSARY, X-CHILDREN, and X-SPOUSE vCard fields
       (Request #8074).
 [jan] Fix copying and moving of image fields (Ryu <ryu@ryux.org>, Bug #8523).
index 028384f..44f37e6 100644 (file)
@@ -951,9 +951,6 @@ class Turba_Driver
         $geo = null;
 
         foreach ($hash as $key => $val) {
-            if (!strlen($val)) {
-                continue;
-            }
             if ($version != '2.1') {
                 $val = Horde_String::convertCharset($val, Horde_Nls::getCharset(), 'utf-8');
             }
@@ -1165,9 +1162,7 @@ class Turba_Driver
 
             case 'businessCategory':
             case 'category':
-                if (!empty($val)) {
-                    $vcard->setAttribute('CATEGORIES', $val);
-                }
+                $vcard->setAttribute('CATEGORIES', $val);
                 break;
 
             case 'anniversary':
@@ -1297,10 +1292,10 @@ class Turba_Driver
         }
 
         $org = array();
-        if (isset($hash['company'])) {
+        if (array_key_exists('company', $hash)) {
             $org[] = $hash['company'];
         }
-        if (isset($hash['department'])) {
+        if (array_key_exists('department', $hash)) {
             $org[] = $hash['department'];
         }
         if (count($org)) {
@@ -1312,11 +1307,14 @@ class Turba_Driver
             $vcard->setAttribute('ORG', $val, Horde_Mime::is8bit($val) ? $charset : array(), false, $org);
         }
 
-        if (isset($hash['commonAddress']) || isset($hash['commonStreet']) ||
-            isset($hash['commonPOBox']) || isset($hash['commonExtended']) ||
-            isset($hash['commonStreet']) || isset($hash['commonCity']) ||
-            isset($hash['commonProvince']) ||
-            isset($hash['commonPostalCode']) || isset($hash['commonCountry'])) {
+        if (array_key_exists('commonAddress', $hash) ||
+            array_key_exists('commonStreet', $hash) ||
+            array_key_exists('commonPOBox', $hash) ||
+            array_key_exists('commonExtended', $hash) ||
+            array_key_exists('commonCity', $hash) ||
+            array_key_exists('commonProvince', $hash) ||
+            array_key_exists('commonPostalCode', $hash) ||
+            array_key_exists('commonCountry', $hash)) {
             /* We can't know if this particular Turba source uses a single
              * address field or multiple for
              * street/city/province/postcode/country. Try to deal with
@@ -1356,11 +1354,14 @@ class Turba_Driver
             $vcard->setAttribute('ADR', $val, $params, true, $a);
         }
 
-        if (isset($hash['homeAddress']) || isset($hash['homeStreet']) ||
-            isset($hash['homePOBox']) || isset($hash['homeExtended']) ||
-            isset($hash['homeStreet']) || isset($hash['homeCity']) ||
-            isset($hash['homeProvince']) || isset($hash['homePostalCode']) ||
-            isset($hash['homeCountry'])) {
+        if (array_key_exists('homeAddress', $hash) ||
+            array_key_exists('homeStreet', $hash) ||
+            array_key_exists('homePOBox', $hash) ||
+            array_key_exists('homeExtended', $hash) ||
+            array_key_exists('homeCity', $hash) ||
+            array_key_exists('homeProvince', $hash) ||
+            array_key_exists('homePostalCode', $hash) ||
+            array_key_exists('homeCountry', $hash)) {
             if (isset($hash['homeAddress']) && !isset($hash['homeStreet'])) {
                 $hash['homeStreet'] = $hash['homeAddress'];
             }
@@ -1395,11 +1396,14 @@ class Turba_Driver
             $vcard->setAttribute('ADR', $val, $params, true, $a);
         }
 
-        if (isset($hash['workAddress']) || isset($hash['workStreet']) ||
-            isset($hash['workPOBox']) || isset($hash['workExtended']) ||
-            isset($hash['workStreet']) || isset($hash['workCity']) ||
-            isset($hash['workProvince']) || isset($hash['workPostalCode']) ||
-            isset($hash['workCountry'])) {
+        if (array_key_exists('workAddress', $hash) ||
+            array_key_exists('workStreet', $hash) ||
+            array_key_exists('workPOBox', $hash) ||
+            array_key_exists('workExtended', $hash) ||
+            array_key_exists('workCity', $hash) ||
+            array_key_exists('workProvince', $hash) ||
+            array_key_exists('workPostalCode', $hash) ||
+            array_key_exists('workCountry', $hash)) {
             if (isset($hash['workAddress']) && !isset($hash['workStreet'])) {
                 $hash['workStreet'] = $hash['workAddress'];
             }
@@ -1475,10 +1479,6 @@ class Turba_Driver
         $hash = array();
         $attr = $vcard->getAllAttributes();
         foreach ($attr as $item) {
-            if (empty($item['value'])) {
-                continue;
-            }
-
             switch ($item['name']) {
             case 'FN':
                 $hash['name'] = $item['value'];