X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fmime.php;h=f253bab241bac10771c936d2f95e0ef16637e2ed;hb=b262c5208d07f9d191cc6cb1dc3cbe5b2da9c89b;hp=8843d2591a8f898e3328ac1cccfb9c6ad87e8a05;hpb=10c0caeba56ea1e7944fecbe1e71c0cbf4d29187;p=squirrelmail.git diff --git a/functions/mime.php b/functions/mime.php index 8843d259..f253bab2 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -342,10 +342,9 @@ function translateText(&$body, $wrap_at, $charset) { * @param string $ent_num (since 1.3.0) message part id * @param integer $id (since 1.3.0) message id * @param string $mailbox (since 1.3.0) imap folder name - * @param boolean $clean (since 1.5.1) Do not output stuff that's irrelevant for the printable version. * @return string html formated message text */ -function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX', $clean=FALSE) { +function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $mailbox='INBOX') { /* This if statement checks for the entity to show as the * primary message. To add more of them, just put them in the * order that is their priority. @@ -359,9 +358,9 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma // workaround for not updated config.php if (! isset($use_iframe)) $use_iframe = false; - if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) { - $view_unsafe_images = false; - } + // If there's no "view_unsafe_images" variable in the URL, turn unsafe + // images off by default. + sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET, FALSE); $body = ''; $urlmailbox = urlencode($mailbox); @@ -401,9 +400,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma $body = trim($body); translateText($body, $wrap_at, $body_message->header->getParameter('charset')); - } elseif ($use_iframe && ! $clean) { - // $clean is used to remove iframe in printable view. - + } elseif ($use_iframe) { /** * If we don't add html message between iframe tags, * we must detect unsafe images and modify $has_unsafe_images. @@ -443,13 +440,20 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma $body_message->header->getParameter('charset')); } - // if this is the clean display (i.e. printer friendly), stop here. - if ( $clean ) { - return $body; - } + /* + * Previously the links for downloading and unsafe images were printed + * under the mail. By putting the links in a global variable we can + * print it in the toolbar where it belongs. Since the original code was + * in this place it's left here. It might be possible to move it to some + * other place if that makes sense. The possibility to do so has not + * been evaluated yet. + */ + // Initialize the global variable to an empty string. + // FIXME: To have $download_and_unsafe_link as a global variable might not be needed since the use of separate variables ($download_href, $unsafe_image_toggle_href, and $unsafe_image_toggle_text) for the templates was introduced. $download_and_unsafe_link = ''; + // Prepare and build a link for downloading the mail. $link = 'passed_id=' . $id . '&ent_id='.$ent_num. '&mailbox=' . $urlmailbox .'&sort=' . $sort . '&startMessage=' . $startMessage . '&show_more=0'; @@ -457,8 +461,16 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma $link .= '&passed_ent_id='.$passed_ent_id; } $download_href = SM_PATH . 'src/download.php?absolute_dl=true&' . $link; + + // Always add the link for downloading the mail as a file to the global + // variable. $download_and_unsafe_link .= "$nbsp|$nbsp" . create_hyperlink($download_href, _("Download this as a file")); + + // Find out the right text to use in the link depending on the + // circumstances. If the unsafe images are displayed the link should + // hide them, if they aren't displayed the link should only appear if + // the mail really contains unsafe images. if ($view_unsafe_images) { $text = _("Hide Unsafe Images"); } else { @@ -469,6 +481,9 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma $text = ''; } } + + // Only create a link for unsafe images if there's need for one. If so: + // add it to the global variable. if($text != '') { $unsafe_image_toggle_href = SM_PATH . 'src/read_body.php?'.$link; $unsafe_image_toggle_text = $text; @@ -480,9 +495,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma } /** - * Generate attachments array for passing to templates. Separated from - * formatAttachments() below so that the same array can be given to the - * print-friendly version. + * Generate attachments array for passing to templates. * * @since 1.5.2 * @param object $message SquirrelMail message object @@ -1829,9 +1842,10 @@ function sq_fix_url($attname, &$attvalue, $message, $id, $mailbox,$sQuote = '"') $attvalue = trim(substr($attvalue,1,-1)); } - if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) { - $view_unsafe_images = false; - } + // If there's no "view_unsafe_images" variable in the URL, turn unsafe + // images off by default. + sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET, FALSE); + $secremoveimg = '../images/' . _("sec_remove_eng.png"); /** @@ -1982,11 +1996,11 @@ function sq_fixstyle($body, $pos, $message, $id, $mailbox){ /** - * First look for general BODY style declaration, which would be - * like so: - * body {background: blah-blah} - * and change it to .bodyclass so we can just assign it to a
- */ + * First look for general BODY style declaration, which would be + * like so: + * body {background: blah-blah} + * and change it to .bodyclass so we can just assign it to a
+ */ $content = preg_replace("|body(\s*\{.*?\})|si", ".bodyclass\\1", $content); $secremoveimg = '../images/' . _("sec_remove_eng.png"); /** @@ -2023,9 +2037,9 @@ function sq_fixstyle($body, $pos, $message, $id, $mailbox){ $content = str_replace($aValue,$aReplace,$content); } - /** - * Remove any backslashes, entities, and extraneous whitespace. - */ + /** + * Remove any backslashes, entities, and extraneous whitespace. + */ $contentTemp = $content; sq_defang($contentTemp); sq_unspace($contentTemp); @@ -2079,8 +2093,8 @@ function sq_cid2http($message, $id, $cidurl, $mailbox){ $cidurl = preg_replace($match_str, $str_rep, $cidurl); $linkurl = find_ent_id($cidurl, $message); - /* in case of non-save cid links $httpurl should be replaced by a sort of - unsave link image */ + /* in case of non-safe cid links $httpurl should be replaced by a sort of + unsafe link image */ $httpurl = ''; /** @@ -2469,9 +2483,11 @@ function magicHTML($body, $id, $message, $mailbox = 'INBOX', $take_mailto_links ) ) ); - if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) { - $view_unsafe_images = false; - } + + // If there's no "view_unsafe_images" variable in the URL, turn unsafe + // images off by default. + sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET, FALSE); + if (!$view_unsafe_images){ /** * Remove any references to http/https if view_unsafe_images set