Skip to content

Commit

Permalink
Use attachment name instead of Content-ID for attachments as per Kola…
Browse files Browse the repository at this point in the history
…b Format 2.0.
  • Loading branch information
yunosh committed Mar 24, 2014
1 parent 54ab31f commit 2e5668e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions framework/Kolab_Storage/lib/Horde/Kolab/Storage/Object.php
Expand Up @@ -321,7 +321,7 @@ public function create(Horde_Kolab_Storage_Folder $folder,
$part = new Horde_Mime_Part();
$part->setType($attachment['type']);
$part->setContents($attachment['content']);
$part->setContentId($name);
$part->setName($name);
$envelope->addPart($part);
}
}
Expand Down Expand Up @@ -383,10 +383,10 @@ public function load($backend_id,
$this->addParseError(self::ERROR_INVALID_KOLAB_PART, $result->getMessage());
} else {
foreach ($structure->getParts() as $part) {
if ($part->getMimeId() == $result[0] || !$part->getContentId()) {
if ($part->getMimeId() == $result[0] || !$part->getName()) {
continue;
}
$this->_data['_attachments'][$part->getContentId()] = array(
$this->_data['_attachments'][$part->getName()] = array(
'type' => $part->getType(),
'content' => $this->_getDriver()->fetchBodypart(
$this->_getFolder(),
Expand Down Expand Up @@ -440,7 +440,7 @@ public function save(Horde_Kolab_Storage_Object_Writer $data)
$part = new Horde_Mime_Part();
$part->setType($attachment['type']);
$part->setContents($attachment['content']);
$part->setContentId($name);
$part->setName($name);
$body->addPart($part);
}
}
Expand Down
6 changes: 4 additions & 2 deletions turba/lib/Driver/Kolab.php
Expand Up @@ -829,11 +829,13 @@ protected function _store($attributes, $object_id = null)
$data = $this->_getListData();
} else {
if (isset($attributes['photo']) && isset($attributes['phototype'])) {
$attributes['_attachments']['photo.attachment'] = array(
$filename = 'photo.'
. Horde_Mime_Magic::mimeToExt($attributes['phototype']);
$attributes['_attachments'][$filename] = array(
'type' => $attributes['phototype'],
'content' => Horde_Stream_Wrapper_String::getStream($attributes['photo'])
);
$attributes['picture'] = 'photo.attachment';
$attributes['picture'] = $filename;
unset($attributes['photo'], $attributes['phototype']);
}

Expand Down

0 comments on commit 2e5668e

Please sign in to comment.