From: Michael M Slusarz Date: Mon, 27 Sep 2010 20:40:27 +0000 (-0600) Subject: Request #6711: pref to choose preferred multipart/alternative display part X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dd7ad25824b6726b89a93d8c08ec1229057aaddf;p=horde.git Request #6711: pref to choose preferred multipart/alternative display part --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 0f5d77316..923e98e32 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -752,10 +752,11 @@ $prefGroups['viewing'] = array( 'label' => _("Message Viewing"), 'desc' => _("Configure how messages are displayed."), 'members' => array( - 'filtering', 'strip_attachments', 'html_image_replacement', - 'html_image_addrbook', 'highlight_text', 'highlight_simple_markup', - 'show_quoteblocks', 'dim_signature', 'emoticons', 'parts_display', - 'mail_hdr', 'default_msg_charset', 'disposition_send_mdn' + 'filtering', 'strip_attachments', 'alternative_display', + 'html_image_replacement', 'html_image_addrbook', 'highlight_text', + 'highlight_simple_markup', 'show_quoteblocks', 'dim_signature', + 'emoticons', 'parts_display', 'mail_hdr', 'default_msg_charset', + 'disposition_send_mdn' ) ); @@ -773,6 +774,18 @@ $_prefs['strip_attachments'] = array( 'type' => 'checkbox', 'desc' => _("Show an icon to allow stripping of attachments from messages?")); +// multipart/alternative part display choice +$_prefs['alternative_display'] = array( + 'value' => 'html', + 'advanced' => true, + 'type' => 'enum', + 'enum' => array( + 'html' => _("HTML part"), + 'text' => _("Plaintext part") + ), + 'desc' => _("For messages with alternative representations of the text part, which part should we display?") +); + // Replace image tags in inline viewed HTML messages with blank images? $_prefs['html_image_replacement'] = array( 'value' => 1, diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 6c82f0168..a033974f0 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-git -------- +[mms] Add preference to control displayed content for multipart/alternative + parts (Request #6711). [mms] Allow multiple messages to be forwarded in a single outgoing message (DIMP) (Request #9132). [mms] Add personal recipient message filter (Request #8659). diff --git a/imp/lib/Mime/Viewer/Alternative.php b/imp/lib/Mime/Viewer/Alternative.php index f5f42b993..a57475c28 100644 --- a/imp/lib/Mime/Viewer/Alternative.php +++ b/imp/lib/Mime/Viewer/Alternative.php @@ -62,19 +62,21 @@ class IMP_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base * Render out the currently set contents. * * @param boolean $inline Are we viewing inline? - * @param boolean $prefer_plain For MIMP, prefer text/plain part over - * all others. + * @param boolean $prefer_plain Prefer text/plain part over all others. * * @return array See parent::render(). */ - protected function _IMPrender($inline, $prefer_plain = true) + protected function _IMPrender($inline, $prefer_plain = null) { $base_id = $this->_mimepart->getMimeId(); $subparts = $this->_mimepart->contentTypeMap(); $base_ids = $display_ids = $ret = array(); - $is_mimp = (IMP::getViewMode() == 'mimp'); + if (is_null($prefer_plain) && + ($GLOBALS['prefs']->getValue('alternative_display') == 'text')) { + $prefer_plain = true; + } /* Look for a displayable part. RFC: show the LAST choice that can be * displayed inline. If an alternative is itself a multipart, the user @@ -85,20 +87,22 @@ class IMP_Mime_Viewer_Alternative extends Horde_Mime_Viewer_Base foreach ($subparts as $mime_id => $type) { $ret[$mime_id] = null; if ((strcmp($base_id, $mime_id) !== 0) && - $this->getConfigParam('imp_contents')->canDisplay($mime_id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL)) { - if (!$is_mimp || - !$prefer_plain || - ($type == 'text/plain')) { - $display_ids[strval($mime_id)] = true; - } + $this->getConfigParam('imp_contents')->canDisplay($mime_id, $inline ? IMP_Contents::RENDER_INLINE : IMP_Contents::RENDER_FULL) && + /* Show HTML if $prefer_plain is false-y or if + * alternative_display is not 'html'. */ + (!$prefer_plain || + (($type != 'text/html') && + (strpos($type, 'text/') === 0)))) { + $display_ids[strval($mime_id)] = true; } } /* If we found no IDs, return now. */ if (empty($display_ids)) { - if ($is_mimp && $prefer_plain) { + if ($prefer_plain && (IMP::getViewMode() == 'mimp')) { return $this->_IMPRender($inline, false); } + $ret[$base_id] = array( 'data' => '', 'status' => array( diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index 719052b35..d961c5ad2 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -313,6 +313,7 @@ class IMP_Prefs_Ui $v = $GLOBALS['injector']->getInstance('IMP_Mime_Viewer')->getViewer($mock_part); if (!$v->canRender('inline')) { + $ui->suppress[] = 'alternative_display'; $ui->suppress[] = 'html_image_replacement'; $ui->suppress[] = 'html_image_addrbook'; }