Handle contact photos in new format
This commit is contained in:
parent
7bc509a2cd
commit
4353615709
3 changed files with 29 additions and 0 deletions
|
@ -179,4 +179,10 @@ abstract class kolab_format
|
|||
*/
|
||||
abstract public function to_array();
|
||||
|
||||
/**
|
||||
* Load object data from Kolab2 format
|
||||
*
|
||||
* @param array Hash array with object properties (produced by Horde Kolab_Format classes)
|
||||
*/
|
||||
abstract public function fromkolab2($object);
|
||||
}
|
||||
|
|
|
@ -202,6 +202,21 @@ class kolab_format_contact extends kolab_format
|
|||
if ($object['anniversary'])
|
||||
$this->obj->setAnniversary(self::get_datetime($object['anniversary'], null, true));
|
||||
|
||||
if (!empty($object['photo'])) {
|
||||
if (strlen($object['photo']) < 255 && ($att = $object['_attachments'][$object['photo']])) {
|
||||
if ($att['content'])
|
||||
$this->obj->setPhoto($att['content'], $att['type']);
|
||||
$object['_attachments'][$object['photo']] = false;
|
||||
}
|
||||
else if ($type = rc_image_content_type($object['photo'])) {
|
||||
$this->obj->setPhoto($object['photo'], $type);
|
||||
$object['_attachments']['photo.attachment'] = false;
|
||||
}
|
||||
}
|
||||
else if (isset($object['photo'])) {
|
||||
$this->obj->setPhoto('','');
|
||||
}
|
||||
|
||||
// handle spouse, children, profession, initials, pgppublickey, etc.
|
||||
|
||||
// cache this data
|
||||
|
@ -292,12 +307,17 @@ class kolab_format_contact extends kolab_format
|
|||
if ($g = $this->obj->gender())
|
||||
$object['gender'] = $g == Contact::Female ? 'female' : 'male';
|
||||
|
||||
if ($this->obj->photoMimetype())
|
||||
$object['photo'] = $this->obj->photo();
|
||||
|
||||
$this->data = $object;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data from old Kolab2 format
|
||||
*
|
||||
* @param array Hash array with object properties
|
||||
*/
|
||||
public function fromkolab2($record)
|
||||
{
|
||||
|
|
|
@ -314,6 +314,9 @@ class kolab_storage_folder
|
|||
if (!isset($object['_attachments'][$name])) {
|
||||
$object['_attachments'][$name] = $old['_attachments'][$name];
|
||||
}
|
||||
// load photo.attachment contents to be directly embedded in xcard block
|
||||
if ($name == 'photo.attachment' && !$object['_attachments'][$name]['content'] && $att['key'])
|
||||
$object['_attachments'][$name]['content'] = $this->get_attachment($object['_msguid'], $att['key'], $object['_mailbox']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue