X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fread_body.php;h=2e1f99872bed384b661570278f8c4041d3d8f780;hb=0880efc9bde776d6aba642cc0fceaedbd6578fe5;hp=dd379b2bf6bf5445540118a038a088367bea5150;hpb=199ff86a842a4a8f7fb12f3b423268b8b33b076d;p=squirrelmail.git diff --git a/src/read_body.php b/src/read_body.php index dd379b2b..2e1f9987 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -115,6 +115,55 @@ function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) { return $result; } +function view_as_html_link($mailbox, $passed_id, $passed_ent_id, $message) { + global $base_uri, $show_html_default; + + $has_html = false; + if ($message->header->type0 == 'message' && $message->header->type1 == 'rfc822') { + $type0 = $message->rfc822_header->content_type->type0; + $type1 = $message->rfc822_header->content_type->type1; + } else { + $type0 = $message->header->type0; + $type1 = $message->header->type1; + } + if($type0 == 'multipart' && + ($type1 == 'alternative' || $type1 == 'mixed' || $type1 == 'related')) { + if ($message->findDisplayEntity(array(), array('text/html'), true)) { + $has_html = true; + } + } + /* + * Normal single part message so check its type. + */ + else { + if($type0 == 'text' && $type1 == 'html') { + $has_html = true; + } + } + if($has_html == true) { + $vars = array('passed_ent_id', 'show_more', 'show_more_cc', 'override_type0', 'override_type1', 'startMessage'); + + $new_link = $base_uri . 'src/read_body.php?passed_id=' . urlencode($passed_id) . + '&passed_ent_id=' . urlencode($passed_ent_id) . + '&mailbox=' . urlencode($mailbox); + foreach($vars as $var) { + if(sqgetGlobalVar($var, $temp)) { + $new_link .= '&' . $var . '=' . urlencode($temp); + } + } + + if($show_html_default == 1) { + $new_link .= '&show_html_default=0'; + $link = _("View as plain text"); + } else { + $new_link .= '&show_html_default=1'; + $link = _("View as HTML"); + } + return ' | ' . $link . ''; + } + return ''; +} + function ServerMDNSupport($aFlags) { /* escaping $ doesn't work -> \x36 */ return ( in_array('$mdnsent',$aFlags,true) || @@ -274,11 +323,11 @@ function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) { } else { unset ($deliver); if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) { - sqimap_append ($imapConnection, $sent_folder, $length); + $sid = sqimap_append ($imapConnection, $sent_folder, $length); require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); $imap_deliver = new Deliver_IMAP(); $imap_deliver->mail($composeMessage, $imapConnection); - sqimap_append_done ($imapConnection); + sqimap_append_done ($imapConnection, $sent_folder); unset ($imap_deliver); } } @@ -708,6 +757,7 @@ function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) { $s .= ' | ' . printer_friendly_link($mailbox, $passed_id, $passed_ent_id); echo $s; + echo view_as_html_link($mailbox, $passed_id, $passed_ent_id, $message); /* Output the download and/or unsafe images link/-s, if any. */ if ($download_and_unsafe_link) { @@ -757,7 +807,11 @@ sqgetGlobalVar('lastTargetMailbox', $lastTargetMailbox, SQ_SESSION); if (!sqgetGlobalVar('messages', $messages, SQ_SESSION) ) { $messages = array(); } - +sqgetGlobalVar('delayed_errors', $delayed_errors, SQ_SESSION); +if (is_array($delayed_errors)) { + $oErrorHandler->AssignDelayedErrors($delayed_errors); + sqsession_unregister("delayed_errors"); +} /** GET VARS */ sqgetGlobalVar('sendreceipt', $sendreceipt, SQ_GET); if (!sqgetGlobalVar('where', $where, SQ_GET) ) { @@ -804,6 +858,18 @@ if ( sqgetGlobalVar('startMessage', $temp) ) { } else { $startMessage = 1; } +if(sqgetGlobalVar('show_html_default', $temp)) { + $show_html_default = (int) $temp; +} + +if(sqgetGlobalVar('view_unsafe_images', $temp)) { + $view_unsafe_images = (int) $temp; + if($view_unsafe_images == 1) { + $show_html_default = 1; + } +} else { + $view_unsafe_images = 0; +} /** * Retrieve mailbox cache */ @@ -905,7 +971,6 @@ if (isset($aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'])) { $message->is_seen = true; $aMailbox['MSG_HEADERS'][$passed_id]['MESSAGE_OBJECT'] = $message; } - if (isset($passed_ent_id) && $passed_ent_id) { $message = $message->getEntity($passed_ent_id); if ($message->type0 != 'message' && $message->type1 != 'rfc822') { @@ -949,8 +1014,6 @@ if (isset($sendreceipt)) { /* End of block for handling incoming url vars */ /***********************************************/ - - $messagebody = ''; do_hook('read_body_top'); if ($show_html_default == 1) { @@ -1039,4 +1102,4 @@ sqimap_logout($imapConnection); $mailbox_cache[$iAccount.'_'.$aMailbox['NAME']] = $aMailbox; sqsession_register($mailbox_cache,'mailbox_cache'); $oTemplate->display('footer.tpl'); -?> \ No newline at end of file +?>