Skip to content
Snippets Groups Projects
Commit 38910e53 authored by Jared Hancock's avatar Jared Hancock Committed by Jared Hancock
Browse files

Support canned responses in email filters

parent 2f4a7efd
No related branches found
No related tags found
No related merge requests found
...@@ -99,6 +99,10 @@ class Filter { ...@@ -99,6 +99,10 @@ class Filter {
return $this->ht['team_id']; return $this->ht['team_id'];
} }
function getCannedResponse() {
return $this->ht['canned_response'];
}
function stopOnMatch(){ function stopOnMatch(){
return ($this->ht['stop_on_match']); return ($this->ht['stop_on_match']);
} }
...@@ -274,6 +278,8 @@ class Filter { ...@@ -274,6 +278,8 @@ class Filter {
if ($email['reply-to-name']) if ($email['reply-to-name'])
$ticket['name'] = $email['reply-to-name']; $ticket['name'] = $email['reply-to-name'];
} }
if ($this->getCannedResponse())
$ticket['canned_response'] = $this->getCannedResponse();
} }
function update($vars,&$errors){ function update($vars,&$errors){
...@@ -395,6 +401,7 @@ class Filter { ...@@ -395,6 +401,7 @@ class Filter {
',reject_email='.db_input(isset($vars['reject_email'])?1:0). ',reject_email='.db_input(isset($vars['reject_email'])?1:0).
',use_replyto_email='.db_input(isset($vars['use_replyto_email'])?1:0). ',use_replyto_email='.db_input(isset($vars['use_replyto_email'])?1:0).
',disable_autoresponder='.db_input(isset($vars['disable_autoresponder'])?1:0). ',disable_autoresponder='.db_input(isset($vars['disable_autoresponder'])?1:0).
',canned_response='.db_input($vars['canned_response']).
',notes='.db_input($vars['notes']); ',notes='.db_input($vars['notes']);
......
...@@ -2004,10 +2004,28 @@ class Ticket{ ...@@ -2004,10 +2004,28 @@ class Ticket{
$autorespond=false; $autorespond=false;
} }
// If a canned-response is immediately queued for this ticket,
// disable the autoresponse
if ($vars['canned_response'])
$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);
if ($vars['canned_response']
&& ($canned = Canned::lookup($vars['canned_response']))) {
$files = array();
foreach ($canned->getAttachments() as $file)
$files[] = $file['id'];
$ticket->postReply(array(
'msgId' => $msgid,
'response' =>
$ticket->replaceTemplateVars($canned->getResponse()),
'cannedattachments' => $files
), null, $errors, true);
}
/************ check if the user JUST reached the max. open tickets limit **********/ /************ check if the user JUST reached the max. open tickets limit **********/
if($cfg->getMaxOpenTickets()>0 if($cfg->getMaxOpenTickets()>0
&& ($client=$ticket->getClient()) && ($client=$ticket->getClient())
......
...@@ -181,6 +181,27 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -181,6 +181,27 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
<strong>Disable</strong> auto-response. <em>(Overwrites Dept. settings)</em> <strong>Disable</strong> auto-response. <em>(Overwrites Dept. settings)</em>
</td> </td>
</tr> </tr>
<tr>
<td width="180">
Canned Response:
</td>
<td>
<select name="canned_response">
<option value="">&mdash; None &mdash;</option>
<?php
if($canneds=Canned::responsesByDeptId($thisstaff->getDeptId())) {
foreach ($canneds as $id => $title) {
$selected=($info['canned_response'] &&
$id==$info['canned_response'])
? 'selected="selected"' : '';
echo sprintf('<option value="%d" %s>%s</option>',
$id, $selected, $title);
}
}
?>
</select>
</td>
</tr>
<tr> <tr>
<td width="180"> <td width="180">
Department: Department:
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#Current version && schema signature (Changes from version to version) #Current version && schema signature (Changes from version to version)
define('THIS_VERSION','1.7-DPR4'); //Shown on admin panel define('THIS_VERSION','1.7-DPR4'); //Shown on admin panel
define('SCHEMA_SIGNATURE','b19dc97d19f7a30f59663c812d1f3ddc'); //MD5 signature of the db schema. (used to trigger upgrades) define('SCHEMA_SIGNATURE','71e05961fdb7a993a21704ae513512bc'); //MD5 signature of the db schema. (used to trigger upgrades)
#load config info #load config info
$configfile=''; $configfile='';
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
**********************************************************************/ **********************************************************************/
require('admin.inc.php'); require('admin.inc.php');
include_once(INCLUDE_DIR.'class.filter.php'); include_once(INCLUDE_DIR.'class.filter.php');
require_once(INCLUDE_DIR.'class.canned.php');
$filter=null; $filter=null;
if($_REQUEST['id'] && !($filter=Filter::lookup($_REQUEST['id']))) if($_REQUEST['id'] && !($filter=Filter::lookup($_REQUEST['id'])))
$errors['err']='Unknown or invalid filter.'; $errors['err']='Unknown or invalid filter.';
......
/**
* Support canned response definition for email filters
*
* @version 1.7-rc1 canned-response-in-filter
*/
ALTER TABLE `%TABLE_PREFIX%email_filter`
ADD `canned_response` int(11) unsigned NOT NULL default '0'
AFTER `disable_autoresponder`;
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
SET `schema_signature`='71e05961fdb7a993a21704ae513512bc';
...@@ -237,6 +237,7 @@ CREATE TABLE `%TABLE_PREFIX%email_filter` ( ...@@ -237,6 +237,7 @@ CREATE TABLE `%TABLE_PREFIX%email_filter` (
`reject_email` tinyint(1) unsigned NOT NULL default '0', `reject_email` tinyint(1) unsigned NOT NULL default '0',
`use_replyto_email` tinyint(1) unsigned NOT NULL default '0', `use_replyto_email` tinyint(1) unsigned NOT NULL default '0',
`disable_autoresponder` tinyint(1) unsigned NOT NULL default '0', `disable_autoresponder` tinyint(1) unsigned NOT NULL default '0',
`canned_response` int(11) unsigned NOT NULL default '0',
`email_id` int(10) unsigned NOT NULL default '0', `email_id` int(10) unsigned NOT NULL default '0',
`priority_id` int(10) unsigned NOT NULL default '0', `priority_id` int(10) unsigned NOT NULL default '0',
`dept_id` int(10) unsigned NOT NULL default '0', `dept_id` int(10) unsigned NOT NULL default '0',
......
b19dc97d19f7a30f59663c812d1f3ddc 71e05961fdb7a993a21704ae513512bc
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