Fix contact picture handling with Kolab format v2
This commit is contained in:
parent
6d75fdd5f3
commit
dfb7fae983
2 changed files with 14 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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']);
|
||||
|
|
Loading…
Add table
Reference in a new issue