From 25b93083732916f202d1a7b07b922a424c453879 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 2 May 2014 13:00:59 -0500 Subject: [PATCH] Fix images in new ticket notice to end user Images placed in the "Issue Details" in a new ticket by staff are not correctly translated to the standard used in the storage model in the %ticket_thread table nor for the standard used by the email system. This patch changes the logic used to create the email template to fetch the sanitized and converted message body from the ThreadEntry instance created rather than reusing the raw message originally sent in the request. References: https://github.com/osTicket/osTicket-1.8/issues/816 --- include/class.ticket.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/include/class.ticket.php b/include/class.ticket.php index 7852ec094..150b64c69 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -528,11 +528,15 @@ class Ticket { } function getLastMessage() { + if (!isset($this->last_message)) { + if($this->getLastMsgId()) + $this->last_message = Message::lookup( + $this->getLastMsgId(), $this->getId()); - if($this->getLastMsgId()) - return Message::lookup($this->getLastMsgId(), $this->getId()); - - return Message::lastByTicketId($this->getId()); + if (!$this->last_message) + $this->last_message = Message::lastByTicketId($this->getId()); + } + return $this->last_message; } function getThread() { @@ -694,6 +698,10 @@ class Ticket { function setLastMsgId($msgid) { return $this->lastMsgId=$msgid; } + function setLastMessage($message) { + $this->last_message = $message; + $this->setLastMsgId($message->getId()); + } //DeptId can NOT be 0. No orphans please! function setDeptId($deptId) { @@ -1542,7 +1550,7 @@ class Ticket { if(!($message = $this->getThread()->addMessage($vars, $errors))) return null; - $this->setLastMsgId($message->getId()); + $this->setLastMessage($message); //Add email recipients as collaborators... if ($vars['recipients'] @@ -2496,7 +2504,7 @@ class Ticket { && ($msg=$tpl->getNewTicketNoticeMsgTemplate()) && ($email=$dept->getEmail())) { - $message = $vars['message']; + $message = (string) $ticket->getLastMessage(); if($response) { $message .= ($cfg->isHtmlThreadEnabled()) ? "<br><br>" : "\n\n"; $message .= $response->getBody(); -- GitLab