From: Jim W. <spi...@us...> - 2007-01-06 05:52:32
|
Update of /cvsroot/moregroupware/mgw/modules/webmail2/inc In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv15906 Modified Files: readmessage_inc.php Log Message: Try to pick out message parts that are simply text/plain and test/html versions of the same information. Only display the html version. Making this follow a webmail2 setting for display html or not would not be a difficult addition, but I am fixing the bug before thinking about making changes to the data. It might be useful to actually compare the text between the pair of parts in question before deleting one of them from memory. Index: readmessage_inc.php =================================================================== RCS file: /cvsroot/moregroupware/mgw/modules/webmail2/inc/readmessage_inc.php,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** readmessage_inc.php 16 Feb 2006 14:12:49 -0000 1.73 --- readmessage_inc.php 6 Jan 2007 05:52:25 -0000 1.74 *************** *** 271,275 **** // } if (!isset($structure->parts)) { ! $structure->parts[0]->headers=$structure->headers; if (isset($structure->ctype_primary)) { $structure->parts[0]->ctype_primary=$structure->ctype_primary; --- 271,277 ---- // } if (!isset($structure->parts)) { ! if (isset($structure->headers)) { ! $structure->parts[0]->headers=$structure->headers; ! } if (isset($structure->ctype_primary)) { $structure->parts[0]->ctype_primary=$structure->ctype_primary; *************** *** 290,317 **** // the next couple of lines are to remove text parts when both // text and html versions are available - $html_found=0; - $text_found=0; - $text_index=0; - $html_index=0; - foreach ($structure->parts as $key=>$part) { - $ctype_full=""; - if (isset($part->ctype_primary) && isset($part->ctype_secondary)) { - $ctype_full=strtolower($part->ctype_primary)."/".strtolower($part->ctype_secondary); - } - if ($ctype_full=="text/plain") { - $text_found=1; - $text_index=$key; - } - if ($ctype_full=="text/html") { - $html_found=1; - $html_index=$key; - } - } - - // for multipart/alternative, we use only the html part // don't we need to check the preferences here? ! if ($structure->ctype_primary=="multipart" && $structure->ctype_secondary=="alternative" && ! $html_found && $text_found) { ! unset($structure->parts[$text_index]); } // end of code to remove text part when html and text parts are there --- 292,299 ---- // the next couple of lines are to remove text parts when both // text and html versions are available // don't we need to check the preferences here? ! $both_parts_key = get_both_html_and_plain_version_key($structure); ! if ($both_parts_key > 0) { ! unset($structure->parts[$both_parts_key]); } // end of code to remove text part when html and text parts are there *************** *** 320,337 **** $partno=0; foreach ($structure->parts as $part) { - // the next happens when you send mail both as text and html - // and with attachments - // sometimes there is a parts[2] as well, but for now I'll leave this - if (isset($part->parts) && isset($part->parts[1]) && isset($part->parts[2]) && strtolower($part->parts[2]->ctype_primary)=="text" && (strtolower($part->parts[2]->ctype_secondary)=="html" || strtolower($part->parts[2]->ctype_secondary)=="enriched")) { - $part = $part->parts[2]; - } else if (isset($part->parts) && isset($part->parts[1])) { - if (strtolower($part->parts[1]->ctype_primary)=="text" && (strtolower($part->parts[1]->ctype_secondary)=="html" || strtolower($part->parts[1]->ctype_secondary)=="enriched")) { - $part = $part->parts[1]; - } else if (empty($part->parts[0]->body)) { - $part = $part->parts[1]; - } else { - $part = $part->parts[0]; - } - } if (isset($part->ctype_primary) && isset($part->ctype_secondary)) { --- 302,305 ---- *************** *** 374,377 **** --- 342,349 ---- if ($ctype_full=="multipart/alternative" || $ctype_full=="multipart/mixed") { + $both_parts_key = get_both_html_and_plain_version_key($part); + if ($both_parts_key > 0) { + unset($part->parts[$both_parts_key]); + } foreach ($part->parts as $party) { list($tmp_body_plain,$tmp_body_show,$tmp_result)=make_emailbox_array($party); *************** *** 476,479 **** --- 448,483 ---- } + function get_both_html_and_plain_version_key($structure) { + // test for this message (or subpart) contains both a plain + // and html version of the same message. currently this will + // return -1 if no duplicate assumed or the key to the part to + // be deleted, which is currently always the text/plain one. + $html_found=0; + $text_found=0; + $text_index=0; + $html_index=0; + foreach ($structure->parts as $key=>$part) { + $ctype_full=""; + if (isset($part->ctype_primary) && isset($part->ctype_secondary)) { + $ctype_full=strtolower($part->ctype_primary)."/".strtolower($part->ctype_secondary); + } + if ($ctype_full=="text/plain" && strlen($part->body) > 10) { + $text_found=1; + $text_index=$key; + if ($html_found) return $text_index; + } + if ($ctype_full=="text/html" || $ctype_full=="text/enriched") { + // if disposition is set assume it is an attachment or insert, + // not a message part. + if (!isset($part->disposition)) { + $html_found=1; + $html_index=$key; + if ($text_found) return $text_index; + } + } + } + return -1; + } + function make_emailbox_html($thearray) { global $msg_no,$settings_replyto,$settings_fullname,$print,$emailsourcelink,$inline,$MGW,$webmails2,$mysize,$word_export,$mbox_id,$global_row; |