#365 Use the ticket/replies HTML property for emails

Check the latest reply, or if there are no replies, the `html` property of the ticket.  If html is 1, then convert html to plaintext, otherwise leave it alone.
merge-requests/2/head
Mike Koch 9 years ago
parent 03afe99284
commit 56e37e1358

@ -672,8 +672,8 @@ function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message
$msg = str_replace('%%MESSAGE_NO_ATTACHMENTS%%', $htmlMessage, $msg); $msg = str_replace('%%MESSAGE_NO_ATTACHMENTS%%', $htmlMessage, $msg);
return str_replace('%%MESSAGE%%', $htmlMessage, $msg); return str_replace('%%MESSAGE%%', $htmlMessage, $msg);
} }
if ($modsForHesk_settings['rich_text_for_tickets'] $message_has_html = checkForHtml($ticket);
|| $modsForHesk_settings['rich_text_for_tickets_for_customers']) { if ($message_has_html) {
if (!function_exists('convert_html_to_text')) { if (!function_exists('convert_html_to_text')) {
require(HESK_PATH . 'inc/html2text/html2text.php'); require(HESK_PATH . 'inc/html2text/html2text.php');
} }
@ -759,8 +759,8 @@ function hesk_processMessage($msg, $ticket, $is_admin, $is_ticket, $just_message
$msg = str_replace('%%MESSAGE%%', $htmlMessage, $msg); $msg = str_replace('%%MESSAGE%%', $htmlMessage, $msg);
} else { } else {
$plainTextMessage = $ticket['message']; $plainTextMessage = $ticket['message'];
if ($modsForHesk_settings['rich_text_for_tickets'] $message_has_html = checkForHtml($ticket);
|| $modsForHesk_settings['rich_text_for_tickets_for_customers']) { if ($message_has_html) {
if (!function_exists('convert_html_to_text')) { if (!function_exists('convert_html_to_text')) {
require(HESK_PATH . 'inc/html2text/html2text.php'); require(HESK_PATH . 'inc/html2text/html2text.php');
} }
@ -842,3 +842,14 @@ function processDirectAttachments($emailMethod, $postfields = NULL, $boundary =
return $attachments; return $attachments;
} }
} }
function checkForHtml($ticket) {
global $hesk_settings;
$repliesRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "replies` WHERE `replyto` = ".intval($ticket['id']) . " ORDER BY `id` DESC LIMIT 1");
if (hesk_dbNumRows($repliesRs) != 1) {
return $ticket['html'];
}
$reply = hesk_dbFetchAssoc($repliesRs);
return $reply['html'];
}

@ -168,7 +168,8 @@ function hesk_newTicket($ticket, $isVerified = true)
'dt' => hesk_date(), 'dt' => hesk_date(),
'lastchange' => hesk_date(), 'lastchange' => hesk_date(),
'id' => hesk_dbInsertID(), 'id' => hesk_dbInsertID(),
'language' => $language 'language' => $language,
'html' => $ticket['html']
); );
// Add custom fields to the array // Add custom fields to the array

Loading…
Cancel
Save