I've been tinkering with showing the full thread on emails and thought I'd share. Please feel free to add any comments etc
Class.ticket.php
Added a new %thread template variable
function replaceTemplateVars($text){
global $cfg;
$dept = $this->getDept();
$staff= $this->getStaff();
$search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/',
'/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/','/%thread/');
$replace = array($this->getId(),
$this->getExtId(),
$this->getEmail(),
$this->getName(),
$this->getSubject(),
$this->getHelpTopic(),
$this->getPhoneNumber(),
$this->getStatus(),
$this->getPriority(),
($dept?$dept->getName():''),
($staff?$staff->getName():''),
Format:($this->getCreateDate()),
Format:($this->getDueDate()),
Format:($this->getCloseDate()),
$cfg->getBaseUrl(),
$this->ticketThread());
return preg_replace($search,$replace,$text);
}
New function for ticketThread in class.ticket.php
function ticketThread(){
$thread="\n\n\n ---------------------------------------------------- \nFull Message Information\n ---------------------------------------------------- \n\n";
$sql='SELECT msg.msg_id,msg.created,msg.message,count(attach_id) as attachments FROM '.TICKET_MESSAGE_TABLE.' msg '.
' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON msg.ticket_id=attach.ticket_id AND msg.msg_id=attach.ref_id AND ref_type='M' ".
' WHERE msg.ticket_id='.db_input($this->id).
' GROUP BY msg.msg_id ORDER BY created';
$msgres =db_query($sql);
while ($msg_row = db_fetch_array($msgres)) {
$thread=$thread . Format:($msg_row);
if($msg_row>0){
$thread=$thread . "(Attachments" . $ticket->getAttachmentStr($msg_row,'M') .")";
}
$thread=$thread . "\n";
$thread=$thread . Format:(Format:($msg_row));
$thread=$thread . "\n\n";
$thread=$thread . "-----------------------------------------------------------------------";
$thread=$thread . "\n\n";
$sql='SELECT resp.*,count(attach_id) as attachments FROM '.TICKET_RESPONSE_TABLE.' resp '.
' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON resp.ticket_id=attach.ticket_id AND resp.response_id=attach.ref_id AND ref_type='R' ".
' WHERE msg_id='.db_input($msg_row).' AND resp.ticket_id='.db_input($this->id).
' GROUP BY resp.response_id ORDER BY created';
$resp =db_query($sql);
while ($resp_row = db_fetch_array($resp)) {
$respID=$resp_row;
$thread=$thread . Format:($resp_row) . "-" . $resp_row;
if($resp_row>0){
$thread=$thread . "( With attachments " . $ticket->getAttachmentStr($respID,'R') . ")";
}
$thread=$thread . "\n";
$thread=$thread . Format:(Format:($resp_row));
$thread=$thread . "\n";
$thread=$thread . "\n";
}
// $msgid =$msg_row;
}
$thread=$thread . "-------------------------End of Message---------------------------";
$thread=$thread . "\n\n";
return $thread;
}
Add a new prompt to staff/template.inc.php for %thread
<tr><td>%url</td><td>osTicket's base url (FQDN)</td></tr>
<tr><td>%thread</td><td>Message thread</td></tr>
Think that is everything.