* html HTML messages
* images Images
* itip iCalendar Transport-Independent Interoperability Protocol
- * notification Notification messages
+ * mdn Message disposition notification messages
* partial message/partial parts
* pdf Portable Document Format (PDF) files
* pgp PGP signed/encrypted messages
*/
$mime_drivers_map['imp']['registered'] = array(
'alternative', 'appledouble', 'enriched', 'html', 'images', 'itip',
- 'notification', 'partial', 'pdf', 'pgp', 'pkcs7', 'plain', 'related',
+ 'mdn', 'partial', 'pdf', 'pgp', 'pkcs7', 'plain', 'related',
'smil', 'status', 'tnef', 'zip'
);
/**
* Disposition Notification message settings
*/
-$mime_drivers['imp']['notification'] = array(
+$mime_drivers['imp']['mdn'] = array(
'inline' => true,
'handles' => array(
'message/disposition-notification'
--- /dev/null
+<?php
+/**
+ * The IMP_Horde_Mime_Viewer_mdn class handles multipart/report messages that
+ * that refer to message disposition notification (MDN) messages (RFC 3798).
+ *
+ * Copyright 2003-2008 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @package Horde_Mime
+ */
+class IMP_Horde_Mime_Viewer_mdn extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * Can this driver render various views?
+ *
+ * @var boolean
+ */
+ protected $_capability = array(
+ 'embedded' => false,
+ 'full' => false,
+ 'info' => true,
+ 'inline' => true,
+ );
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ /* If this is a straight message/disposition-notification part, just
+ * output the text. */
+ if ($this->_mimepart->getType() == 'message/disposition-notification') {
+ return $this->_params['contents']->renderMIMEPart($this->_mimepart->getMIMEId(), 'full', array('type' => 'text/plain', 'params' => $this->_params));
+ }
+
+ return $this->_renderInfo();
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInfo()
+ {
+ $parts = $this->_mimepart->contentTypeMap();
+ $status = array(
+ array(
+ 'icon' => Horde::img('info_icon.png', _("Info"), null, $GLOBALS['registry']->getImageDir('horde')),
+ 'text' => array(_("A message you have sent has resulted in a return notification from the recipient."))
+ )
+ );
+
+ /* RFC 3798 [3]: There are three parts to a delivery status
+ * multipart/report message:
+ * (1) Human readable message
+ * (2) Machine parsable body part (message/disposition-notification)
+ * (3) Original message (optional) */
+
+ /* Print the human readable message. */
+ $curr_id = Horde_Mime::mimeIdArithmetic($this->_mimepart->getMIMEId(), 'down');
+ $first_part = $this->_params['contents']->renderMIMEPart($curr_id, 'inlineauto', array('params' => $this->_params));
+
+ /* Display a link to more detailed message. */
+ $curr_id = Horde_Mime::mimeIdArithmetic($curr_id, 'next');
+ $part = $this->_params['contents']->getMIMEPart($curr_id);
+ if ($part) {
+ $status[0]['text'][] = sprintf(_("Additional information can be viewed %s."), $this->_params['contents']->linkViewJS($part, 'view_attach', _("HERE"), array('jstext' => _("Additional information details"), 'params' => array('mode' => 'inline'))));
+ }
+
+ /* Display a link to the sent message. Try to download the text of
+ the message/rfc822 part first, if it exists. */
+ $curr_id = Horde_Mime::mimeIdArithmetic($curr_id, 'next');
+ $part = $this->_params['contents']->getMIMEPart($curr_id);
+ if ($part) {
+ $status[0]['text'][] = sprintf(_("The text of the sent message can be viewed %s."), $this->_params['contents']->linkViewJS($part, 'view_attach', _("HERE"), array('jstext' => _("The text of the sent message"))));
+ }
+
+ if (empty($first_part)) {
+ $data = '';
+ } else {
+ $status[0]['text'][] = _("The mail server generated the following informational message:");
+ $status = array_merge($status, $first_part['status']);
+ $data = $first_part['data'];
+ }
+
+ return array(
+ 'data' => $data,
+ 'ids' => array_keys($parts),
+ 'status' => $status,
+ 'type' => 'text/html; charset=' . NLS::getCharset()
+ );
+ }
+}
+++ /dev/null
-<?php
-/**
- * The IMP_Horde_Mime_Viewer_notification class handles multipart/report
- * messages that refer to mail notification messages (RFC 2298).
- *
- * Copyright 2003-2008 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @package Horde_Mime
- */
-class IMP_Horde_Mime_Viewer_notification extends Horde_Mime_Viewer_Driver
-{
- /**
- * Render out the currently set contents.
- *
- * @param array $params An array with a reference to a MIME_Contents
- * object.
- *
- * @return string The rendered text in HTML.
- */
- public function render($params)
- {
- $contents = &$params[0];
-
- /* If this is a straight message/disposition-notification part, just
- output the text. */
- if ($this->mime_part->getType() == 'message/disposition-notification') {
- $part = new MIME_Part('text/plain');
- $part->setContents($this->mime_part->getContents());
- return '<pre>' . htmlspecialchars($contents->renderMIMEPart($part)) . '</pre>';
- }
-
- global $registry;
-
- /* RFC 2298 [3]: There are three parts to a delivery status
- multipart/report message:
- (1) Human readable message
- (2) Machine parsable body part (message/disposition-notification)
- (3) Original message (optional) */
-
- /* Print the human readable message. */
- $part = $contents->getDecodedMIMEPart($this->mime_part->getRelativeMIMEId(1));
- $status = array(
- _("A message you have sent has resulted in a return notification from the recipient."),
- _("The mail server generated the following informational message:")
- );
- $statusimg = Horde::img('alerts/message.png', _("Attention"), 'height="16" width="16"', $registry->getImageDir('horde'));
- $text = $this->formatStatusMsg($status, $statusimg) .
- '<blockquote>' . $contents->renderMIMEPart($part) . '</blockquote>' . "\n";
-
- /* Display a link to more detailed message. */
- $part = $contents->getDecodedMIMEPart($this->mime_part->getRelativeMIMEId(2));
- if ($part) {
- $statusimg = Horde::img('info_icon.png', _("Info"), 'height="16" width="16"', $registry->getImageDir('horde'));
- $status = array(sprintf(_("Additional information can be viewed %s."), $contents->linkViewJS($part, 'view_attach', _("HERE"), _("Additional information details"))));
- }
-
- /* Display a link to the sent message. Try to download the text of
- the message/rfc822 part first, if it exists. */
- if (($part = $contents->getDecodedMIMEPart($this->mime_part->getRelativeMIMEId('3.0'))) ||
- ($part = $contents->getDecodedMIMEPart($this->mime_part->getRelativeMIMEId(3)))) {
- $status[] = sprintf(_("The text of the sent message can be viewed %s."), $contents->linkViewJS($part, 'view_attach', _("HERE"), _("The text of the sent message")));
- }
-
- $text .= $this->formatStatusMsg($status, $statusimg, false);
-
- return $text;
- }
-
- /**
- * Return the content-type.
- *
- * @return string The content-type of the message.
- */
- public function getType()
- {
- return 'text/html; charset=' . NLS::getCharset();
- }
-}