summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-11-08 13:07:01 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-11-08 13:07:01 (GMT)
commitdfb7fae98367bf59540aff43979539cfc1ff27d1 (patch)
tree19ccc3dc24aafb597525c0b82d1dc07c6ef65dca
parent6d75fdd5f317d33d4f42208397de21e7fce47aed (diff)
downloadroundcubemail-plugins-kolab-dfb7fae98367bf59540aff43979539cfc1ff27d1.tar.gz
Fix contact picture handling with Kolab format v2
-rw-r--r--plugins/libkolab/lib/kolab_format_contact.php2
-rw-r--r--plugins/libkolab/lib/kolab_storage_folder.php14
2 files changed, 14 insertions, 2 deletions
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index 9dedcb1..b147c38 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -379,6 +379,8 @@ class kolab_format_contact extends kolab_format
if ($this->obj->photoMimetype())
$object['photo'] = $this->obj->photo();
+ else if ($this->xmlobject && ($photo_name = $this->xmlobject->pictureAttachmentName()))
+ $object['photo'] = $photo_name;
// relateds -> spouse, children
$this->read_relateds($this->obj->relateds(), $object);
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index 54aed7a..682ca7e 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -540,13 +540,23 @@ class kolab_storage_folder
unset($object['_attachments'][$key]);
}
// load photo.attachment from old Kolab2 format to be directly embedded in xcard block
- else if ($key == 'photo.attachment' && !isset($object['photo']) && !$object['_attachments'][$key]['content'] && $att['id']) {
- $object['photo'] = $this->get_attachment($object['_msguid'], $att['id'], $object['_mailbox']);
+ else if ($type == 'contact' && ($key == 'photo.attachment' || $key == 'kolab-picture.png') && $att['id']) {
+ if (!isset($object['photo']))
+ $object['photo'] = $this->get_attachment($object['_msguid'], $att['id'], $object['_mailbox']);
unset($object['_attachments'][$key]);
}
}
}
+ // save contact photo to attachment for Kolab2 format
+ if (kolab_storage::$version == 2.0 && $object['photo'] && !$existing_photo) {
+ $attkey = 'kolab-picture.png'; // this file name is hard-coded in libkolab/kolabformatV2/contact.cpp
+ $object['_attachments'][$attkey] = array(
+ 'mimetype'=> rc_image_content_type($object['photo']),
+ 'content' => preg_match('![^a-z0-9/=+-]!i', $object['photo']) ? $object['photo'] : base64_decode($object['photo']),
+ );
+ }
+
// generate unique keys (used as content-id) for attachments
if (is_array($object['_attachments'])) {
$numatt = count($object['_attachments']);