From 46b0a0ea98a0e33dfb6aefa492c8b5c8dcf13484 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 28 Aug 2009 13:07:32 +0000 Subject: [PATCH] improvement of the import of eMails if bodystructure is cascaded deeper than expected --- infolog/inc/class.infolog_ui.inc.php | 66 +++++++++++++++++----------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index d78847ea07..c98d432e8f 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1450,32 +1450,8 @@ class infolog_ui $subject = $bofelamimail->decode_header($headers['SUBJECT']); - for($i=0; $itranslation->convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); - if ($bodyParts[$i]['mimeType'] == 'text/html') { - // convert HTML to text, as we dont want HTML in infologs - $newBody = $bofelamimail->convertHTMLToText($newBody,true); - $bofelamimail->getCleanHTML($newBody); // new Body passed by reference - $message .= $newBody; - continue; - } - $newBody = strip_tags($newBody); - $newBody = explode("\n",$newBody); - // create it new, with good line breaks - reset($newBody); - while(list($key,$value) = @each($newBody)) - { - if (trim($value) != '') { - #if ($value != "\r") $value .= "\n"; - } else { - // if you want to strip all empty lines uncomment the following - #continue; - } - $message .= $bofelamimail->wordwrap($value,75,"\n"); - } - } + $message = self::getdisplayableBody($bofelamimail, $bodyParts); + //_debug_array($attachments); if (is_array($attachments)) { @@ -1544,6 +1520,44 @@ class infolog_ui ); } + static function &getdisplayableBody(&$bofelamimail, $bodyParts) + { + for($i=0; $itranslation->convert($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); + + if ($bodyParts[$i]['mimeType'] == 'text/html') { + // convert HTML to text, as we dont want HTML in infologs + $newBody = $bofelamimail->convertHTMLToText($newBody,true); + $bofelamimail->getCleanHTML($newBody); // new Body passed by reference + $message .= $newBody; + continue; + } + $newBody = strip_tags($newBody); + $newBody = explode("\n",$newBody); + // create it new, with good line breaks + reset($newBody); + while(list($key,$value) = @each($newBody)) + { + if (trim($value) != '') { + #if ($value != "\r") $value .= "\n"; + } else { + // if you want to strip all empty lines uncomment the following + #continue; + } + $message .= $bofelamimail->wordwrap($value,75,"\n"); + } + } + return $message; + } + /** * shows infolog in other applications *