Skip to content
Snippets Groups Projects
Commit e905a119 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add postCannedReply function

parent 03ff0189
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ include_once(INCLUDE_DIR.'class.template.php'); ...@@ -29,6 +29,7 @@ include_once(INCLUDE_DIR.'class.template.php');
include_once(INCLUDE_DIR.'class.variable.php'); include_once(INCLUDE_DIR.'class.variable.php');
include_once(INCLUDE_DIR.'class.priority.php'); include_once(INCLUDE_DIR.'class.priority.php');
include_once(INCLUDE_DIR.'class.sla.php'); include_once(INCLUDE_DIR.'class.sla.php');
include_once(INCLUDE_DIR.'class.canned.php');
class Ticket { class Ticket {
...@@ -1423,6 +1424,22 @@ class Ticket { ...@@ -1423,6 +1424,22 @@ class Ticket {
return $msgid; return $msgid;
} }
function postCannedReply($canned, $msgId, $alert=true) {
if((!is_object($canned) && !($canned=Canned::lookup($canned))) || !$canned->isEnabled())
return false;
$files = array();
foreach ($canned->getAttachments() as $file)
$files[] = $file['id'];
$info = array('msgId' => $msgId,
'response' => $this->replaceVars($canned->getResponse()),
'cannedattachments' => $files);
return $this->postReply($info, $errors, $alert);
}
/* public */ /* public */
function postReply($vars, $errors, $alert = true) { function postReply($vars, $errors, $alert = true) {
global $thisstaff, $cfg; global $thisstaff, $cfg;
...@@ -2063,18 +2080,15 @@ class Ticket { ...@@ -2063,18 +2080,15 @@ class Ticket {
//Auto assign staff or team - auto assignment based on filter rules. //Auto assign staff or team - auto assignment based on filter rules.
if($vars['staffId'] && !$vars['assignId']) if($vars['staffId'] && !$vars['assignId'])
$ticket->assignToStaff($vars['staffId'],'auto-assignment'); $ticket->assignToStaff($vars['staffId'], 'Auto Assignment');
if($vars['teamId'] && !$vars['assignId']) if($vars['teamId'] && !$vars['assignId'])
$ticket->assignToTeam($vars['teamId'],'auto-assignment'); $ticket->assignToTeam($vars['teamId'], 'Auto Assignment');
/********** double check auto-response ************/ /********** double check auto-response ************/
//Overwrite auto responder if the FROM email is one of the internal emails...loop control. //Overwrite auto responder if the FROM email is one of the internal emails...loop control.
if($autorespond && (Email::getIdByEmail($ticket->getEmail()))) if($autorespond && (Email::getIdByEmail($ticket->getEmail())))
$autorespond=false; $autorespond=false;
if($autorespond && $dept && !$dept->autoRespONNewTicket())
$autorespond=false;
# Messages that are clearly auto-responses from email systems should # Messages that are clearly auto-responses from email systems should
# not have a return 'ping' message # not have a return 'ping' message
if ($autorespond && $vars['header'] && if ($autorespond && $vars['header'] &&
...@@ -2089,25 +2103,18 @@ class Ticket { ...@@ -2089,25 +2103,18 @@ class Ticket {
$autorespond=false; $autorespond=false;
} }
//post canned auto-response IF any (disables new ticket auto-response).
if ($vars['cannedResponseId'] if ($vars['cannedResponseId']
&& ($canned = Canned::lookup($vars['cannedResponseId'])) && $ticket->postCannedReply($vars['cannedResponseId'], $msgid, $autorespond)) {
&& $canned->isEnabled()) { $ticket->markUnAnswered(); //Leave the ticket as unanswred.
$files = array(); $autorespond = false;
foreach ($canned->getAttachments() as $file)
$files[] = $file['id'];
$ticket->postReply(
array(
'msgId' => $msgid,
'response' =>
$ticket->replaceVars($canned->getResponse()),
'cannedattachments' => $files
),$errors, true);
// If a canned-response is immediately queued for this ticket,
// disable the autoresponse
$autorespond=false;
} }
//Check department's auto response settings
// XXX: Dept. setting doesn't affect canned responses.
if($autorespond && $dept && !$dept->autoRespONNewTicket())
$autorespond=false;
/***** See if we need to send some alerts ****/ /***** See if we need to send some alerts ****/
$ticket->onNewTicket($vars['message'], $autorespond, $alertstaff); $ticket->onNewTicket($vars['message'], $autorespond, $alertstaff);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment