From 91da3a3bba0161b9456864928e1ff353b786ecbb Mon Sep 17 00:00:00 2001 From: "Aleksander Machniak (Kolab Systems)" Date: Wed, 27 Jul 2011 14:46:40 +0200 Subject: [PATCH] Fixed merging address fields on contact update --- .../kolab_addressbook/lib/rcube_kolab_contacts.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 6cc0289b..9b97b64d 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -1092,10 +1092,13 @@ class rcube_kolab_contacts extends rcube_addressbook } } + $object['address'] = array(); + foreach ($this->get_col_values('address', $contact) as $type => $values) { if ($this->addresstypemap[$type]) $type = $this->addresstypemap[$type]; + $updated = false; $basekey = 'addr-' . $type . '-'; foreach ((array)$values as $adr) { // switch type if slot is already taken @@ -1111,8 +1114,16 @@ class rcube_kolab_contacts extends rcube_addressbook $object[$basekey . 'postal-code'] = $adr['zipcode']; $object[$basekey . 'region'] = $adr['region']; $object[$basekey . 'country'] = $adr['country']; + + // Update existing address entry of this type + foreach($object['address'] as $index => $address) { + if ($address['type'] == $type) { + $object['address'][$index] = $new_address; + $updated = true; + } + } } - else { + if (!$updated) { $object['address'][] = array( 'type' => $type, 'street' => $adr['street'],