From: Michael M Slusarz Date: Wed, 12 Nov 2008 21:47:59 +0000 (-0700) Subject: notification -> mdn; update the Viewer. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ed50a9b94eb89e5e19c68698e547407ede1b0e26;p=horde.git notification -> mdn; update the Viewer. --- diff --git a/imp/config/mime_drivers.php.dist b/imp/config/mime_drivers.php.dist index 24443f35e..9681df7c7 100644 --- a/imp/config/mime_drivers.php.dist +++ b/imp/config/mime_drivers.php.dist @@ -21,7 +21,7 @@ * 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 @@ -35,7 +35,7 @@ */ $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' ); @@ -191,7 +191,7 @@ $mime_drivers['imp']['status'] = array( /** * Disposition Notification message settings */ -$mime_drivers['imp']['notification'] = array( +$mime_drivers['imp']['mdn'] = array( 'inline' => true, 'handles' => array( 'message/disposition-notification' diff --git a/imp/lib/Mime/Viewer/mdn.php b/imp/lib/Mime/Viewer/mdn.php new file mode 100644 index 000000000..bea75eb35 --- /dev/null +++ b/imp/lib/Mime/Viewer/mdn.php @@ -0,0 +1,99 @@ + + * @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() + ); + } +} diff --git a/imp/lib/Mime/Viewer/notification.php b/imp/lib/Mime/Viewer/notification.php deleted file mode 100644 index 216e3e62f..000000000 --- a/imp/lib/Mime/Viewer/notification.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @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 '
' . htmlspecialchars($contents->renderMIMEPart($part)) . '
'; - } - - 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) . - '
' . $contents->renderMIMEPart($part) . '
' . "\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(); - } -}