Index: include/staff/templates.inc.php =================================================================== --- include/staff/templates.inc.php +++ include/staff/templates.inc.php @@ -160,5 +160,6 @@ %assignerStaff assigning the ticket %urlosTicket's base url (FQDN) - + %quoteQuote last incomming message + %quote_firstQuote first incomming message Index: include/class.ticket.php =================================================================== --- include/class.ticket.php +++ include/class.ticket.php @@ -296,4 +296,26 @@ return $createDate; } + + function getLastMessage($type='last') { + if($this->lastmsgdate) + return $this->lastmsgdate; + + //for old versions... + $createDate=0; + $sql ='SELECT message FROM '.TICKET_MESSAGE_TABLE.' WHERE ticket_id='.db_input($this->getId()).' ORDER BY created '.($type=='last'?'DESC':'ASC').' LIMIT 1'; + if(($res=db_query($sql)) && db_num_rows($res)) + list($message)=db_fetch_row($res); + + return ($message); + } + + function quoteMessage($type='last'){ + $message = $this->getLastMessage($type); + $quoted = ""; + foreach(explode("\n", $message) as $line){ + $quoted .= ">".$line; + } + return $quoted; + } function getLastResponseDate() { @@ -423,5 +445,5 @@ $search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/', - '/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/'); + '/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/','/%quote_first/','/%quote/'); $replace = array($this->getId(), $this->getExtId(), @@ -438,5 +460,7 @@ Format::db_daydatetime($this->getDueDate()), Format::db_daydatetime($this->getCloseDate()), - $cfg->getBaseUrl()); + $cfg->getBaseUrl(), + $this->quoteMessage('first'), + $this->quoteMessage('last')); return preg_replace($search,$replace,$text); }