From b97b9bf1d5a149f68b00aa19f9eae4217fc7796a Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 25 May 2016 08:59:26 +0000 Subject: [PATCH] $this->head_html(log)$ and $this->head(log)$ now support both text and HTML case logs. SVN:trunk[4136] --- core/attributedef.class.inc.php | 4 ++-- core/ormcaselog.class.inc.php | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 0588ce7cf..3d0158c0f 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -2915,10 +2915,10 @@ class AttributeCaseLog extends AttributeLongText return $value->GetText(); case 'head': - return $value->GetLatestEntry(); + return $value->GetLatestEntry('text'); case 'head_html': - return '
'.str_replace( array( "\r\n", "\n", "\r"), "
", htmlentities($value->GetLatestEntry(), ENT_QUOTES, 'UTF-8')).'
'; + return $value->GetLatestEntry('html'); case 'html': return $value->GetAsEmailHtml(); diff --git a/core/ormcaselog.class.inc.php b/core/ormcaselog.class.inc.php index 39e0e7613..d9ec1dcfa 100644 --- a/core/ormcaselog.class.inc.php +++ b/core/ormcaselog.class.inc.php @@ -651,12 +651,38 @@ class ormCaseLog { /** * Get the latest entry from the log + * @param string The expected output format text|html * @return string */ - public function GetLatestEntry() + public function GetLatestEntry($sFormat = 'text') { + $sRes = ''; $aLastEntry = end($this->m_aIndex); - $sRes = substr($this->m_sLog, $aLastEntry['separator_length'], $aLastEntry['text_length']); + $sRaw = substr($this->m_sLog, $aLastEntry['separator_length'], $aLastEntry['text_length']); + switch($sFormat) + { + case 'text': + if ($aLastEntry['format'] == 'text') + { + $sRes = $sRaw; + } + else + { + $sRes = utils::HtmlToText($sRaw); + } + break; + + case 'html': + if ($aLastEntry['format'] == 'text') + { + $sRes = utils::TextToHtml($sRaw); + } + else + { + $sRes = $sRaw; + } + break; + } return $sRes; }