From fd40f882a732063729a7a0f88c2374cf3f0c3296 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Sun, 29 Sep 2013 03:43:16 +0000 Subject: [PATCH] Change last message lookup to use ticket_id instead of external ticket id/number. * Ticket number will be customization in the future * Ticket thread only link to Ticket should be internal ticket id. --- include/class.thread.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/include/class.thread.php b/include/class.thread.php index 8f108d705..d5442eb3d 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -783,15 +783,16 @@ class Message extends ThreadEntry { )?$m:null; } - function lastByExtTicketId($ticketId) { - $sql = 'SELECT thread.id FROM '.TICKET_THREAD_TABLE - .' thread JOIN '.TICKET_TABLE.' ticket ON (ticket.ticket_id = thread.ticket_id) - WHERE thread_type=\'M\' AND ticket.ticketID = '.db_input($ticketId) + function lastByTicketId($ticketId) { + + $sql=' SELECT thread.id FROM '.TICKET_THREAD_TABLE.' thread ' + .' WHERE thread_type=\'M\' AND thread.ticket_id = '.db_input($ticketId) .' ORDER BY thread.id DESC LIMIT 1'; - if (($res = db_query($sql)) && (list($id) = db_fetch_row($res))) + + if (($res = db_query($sql)) && ($id = db_result($res))) return Message::lookup($id); - else - return null; + + return null; } } -- GitLab