From 7573112fcc4ec3909df65c23fdb5e0f245863094 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Wed, 3 Oct 2012 15:17:09 -0400 Subject: [PATCH] Support ticket lookup using ticket # AND optional email --- include/class.ticket.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/class.ticket.php b/include/class.ticket.php index ed09921c3..d91f8f46e 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1766,8 +1766,17 @@ class Ticket { /*============== Static functions. Use Ticket::function(params); ==================*/ - function getIdByExtId($extid) { - $sql ='SELECT ticket_id FROM '.TICKET_TABLE.' ticket WHERE ticketID='.db_input($extid); + function getIdByExtId($extId, $email=null) { + + if(!$extId || !is_numeric($extId)) + return 0; + + $sql ='SELECT ticket_id FROM '.TICKET_TABLE.' ticket ' + .' WHERE ticketID='.db_input($extId); + + if($email) + $sql.=' AND email='.db_input($email); + if(($res=db_query($sql)) && db_num_rows($res)) list($id)=db_fetch_row($res); @@ -1780,8 +1789,8 @@ class Ticket { return ($id && is_numeric($id) && ($ticket= new Ticket($id)) && $ticket->getId()==$id)?$ticket:null; } - function lookupByExtId($id) { - return self::lookup(self:: getIdByExtId($id)); + function lookupByExtId($id, $email=null) { + return self::lookup(self:: getIdByExtId($id, $email)); } function genExtRandID() { -- GitLab