From: indiri69 Date: Thu, 9 Feb 2006 21:44:21 +0000 (+0000) Subject: Merged View as HTML support into the SquirrelMail core X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7277191e3032e73f380452f59bd6634f479d464f;p=squirrelmail.git Merged View as HTML support into the SquirrelMail core git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10683 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index e3108fd2..978eb9fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -544,6 +544,7 @@ Version 1.5.1 -- CVS - Added options to disable THREAD and SORT extension. - Fixed mailbox cache issues caused by using prev/next links in read_body.php. + - Added View as HTML support to the SquirrelMail core. Version 1.5.0 - 2 February 2004 ------------------------------- diff --git a/src/read_body.php b/src/read_body.php index dd379b2b..77f4aafd 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) || @@ -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) { @@ -804,6 +854,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 */ @@ -949,8 +1011,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 +1099,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 +?>