From 892d91af3eaeea4e0900b9cf8bb1a53c8f4ff6ec Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 31 Dec 2012 17:41:30 +0100 Subject: [PATCH] Fix saving birthday date in XML after import from vCard --- .../kolab_addressbook/lib/rcube_kolab_contacts.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index bb6ef24c..a09a1e7d 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -559,7 +559,7 @@ class rcube_kolab_contacts extends rcube_addressbook // generate new Kolab contact item $object = $this->_from_rcube_contact($save_data); - $saved = $this->storagefolder->save($object, 'contact'); + $saved = $this->storagefolder->save($object, 'contact'); if (!$saved) { rcube::raise_error(array( @@ -605,7 +605,7 @@ class rcube_kolab_contacts extends rcube_addressbook else { $this->contacts[$id] = $this->_to_rcube_contact($object); $updated = true; - + // TODO: update data in groups this contact is member of } } @@ -1163,6 +1163,14 @@ class rcube_kolab_contacts extends rcube_addressbook $contact[$key] = $val; } + // convert one-item-array elements into string element + // this is needed e.g. to properly import birthday field + foreach ($this->coltypes as $type => $col_def) { + if ($col_def['limit'] == 1 && is_array($contact[$type])) { + $contact[$type] = array_shift(array_filter($contact[$type])); + } + } + // add empty values for some fields which can be removed in the UI return array_filter($contact) + array('nickname' => '', 'birthday' => '', 'anniversary' => '', 'freebusyurl' => '', 'photo' => $contact['photo']); }