$tnef = Horde_Compress::factory('tnef');
$tnefData = $tnef->decompress($this->_mimepart->getContents());
- $text = '';
-
if (!count($tnefData)) {
- $status = array(
- 'text' => array(_("No attachments found."))
- );
- } else {
- $status = array(
- 'text' => array(_("The following files were attached to this part:"))
+ /* Ignore attachment if it doesn't contain any files. */
+ return array(
+ $this->_mimepart->getMimeId() => null
);
+ }
- reset($tnefData);
- while (list($key, $data) = each($tnefData)) {
- $temp_part = $this->_mimepart;
- $temp_part->setName($data['name']);
- $temp_part->setDescription($data['name']);
+ $text = '';
- /* Short-circuit MIME-type guessing for winmail.dat parts;
- * we're showing enough entries for them already. */
- $type = $data['type'] . '/' . $data['subtype'];
- if (in_array($type, array('application/octet-stream', 'application/base64'))) {
- $type = Horde_Mime_Magic::filenameToMIME($data['name']);
- }
- $temp_part->setType($type);
+ reset($tnefData);
+ while (list($key, $data) = each($tnefData)) {
+ $temp_part = $this->_mimepart;
+ $temp_part->setName($data['name']);
+ $temp_part->setDescription($data['name']);
- $link = $this->_params['contents']->linkView($temp_part, 'view_attach', htmlspecialchars($data['name']), array('jstext' => sprintf(_("View %s"), $data['name']), 'params' => array('tnef_attachment' => $key + 1)));
- $text .= _("Attached File:") . ' ' . $link . ' (' . $data['type'] . '/' . $data['subtype'] . ")<br />\n";
+ /* Short-circuit MIME-type guessing for winmail.dat parts;
+ * we're showing enough entries for them already. */
+ $type = $data['type'] . '/' . $data['subtype'];
+ if (in_array($type, array('application/octet-stream', 'application/base64'))) {
+ $type = Horde_Mime_Magic::filenameToMIME($data['name']);
}
+ $temp_part->setType($type);
+
+ $link = $this->_params['contents']->linkView($temp_part, 'view_attach', htmlspecialchars($data['name']), array('jstext' => sprintf(_("View %s"), $data['name']), 'params' => array('tnef_attachment' => $key + 1)));
+ $text .= _("Attached File:") . ' ' . $link . ' (' . $data['type'] . '/' . $data['subtype'] . ")<br />\n";
}
return array(
$this->_mimepart->getMimeId() => array(
'data' => $text,
- 'status' => array($status),
+ 'status' => array(
+ array(
+ 'text' => array(_("The following files were attached to this part:"))
+ )
+ ),
'type' => 'text/html; charset=' . Horde_Nls::getCharset()
)
);
}
+
}