Skip to content

Commit

Permalink
Fix output of message/rfc822 parts when downloading all attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Apr 22, 2014
1 parent 776517b commit 405e1c2
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions imp/lib/Contents/View.php
Expand Up @@ -60,9 +60,8 @@ public function downloadAll()

$tosave = array();
foreach ($this->_contents->downloadAllList() as $val) {
$mime = $this->_contents->getMIMEPart($val);
$name = $mime->getName(true);
if (!$name) {
$mime = $this->_getRawDownloadPart($val);
if (!($name = $mime->getName(true))) {
$name = sprintf(_("part %s"), $val);
}
$tosave[] = array(
Expand Down Expand Up @@ -92,15 +91,7 @@ public function downloadAttach($id, $zip = false)

$session->close();

$mime = $this->_contents->getMIMEPart($id);
if ($this->_contents->canDisplay($id, IMP_Contents::RENDER_RAW)) {
$render = $this->_contents->renderMIMEPart($id, IMP_Contents::RENDER_RAW);
$part = reset($render);
$mime->setContents($part['data'], array(
'encoding' => 'binary'
));
}

$mime = $this->_getRawDownloadPart($id);
$name = $this->_contents->getPartName($mime);

/* Compress output? */
Expand Down Expand Up @@ -402,4 +393,28 @@ static public function addToken(array $params = array())
return $params;
}

/* Internal methods. */

/**
* Get a MIME Part for use in creating download.
*
* @param string $id MIME ID.
*
* @return Horde_Mime_Part MIME part.
*/
protected function _getRawDownloadPart($id)
{
$mime = $this->_contents->getMIMEPart($id);

if ($this->_contents->canDisplay($id, IMP_Contents::RENDER_RAW)) {
$render = $this->_contents->renderMIMEPart($id, IMP_Contents::RENDER_RAW);
$part = reset($render);
$mime->setContents($part['data'], array(
'encoding' => 'binary'
));
}

return $mime;
}

}

0 comments on commit 405e1c2

Please sign in to comment.