diff --git a/include/class.filter.php b/include/class.filter.php index 9c3065c10aba5aa1e359e4c36a67e4de83aec9fe..396d45050dc06414d9efa9b37f831721a1fe5cf1 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -99,6 +99,10 @@ class Filter { return $this->ht['team_id']; } + function getCannedResponse() { + return $this->ht['canned_response']; + } + function stopOnMatch(){ return ($this->ht['stop_on_match']); } @@ -274,6 +278,8 @@ class Filter { if ($email['reply-to-name']) $ticket['name'] = $email['reply-to-name']; } + if ($this->getCannedResponse()) + $ticket['canned_response'] = $this->getCannedResponse(); } function update($vars,&$errors){ @@ -395,6 +401,7 @@ class Filter { ',reject_email='.db_input(isset($vars['reject_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). + ',canned_response='.db_input($vars['canned_response']). ',notes='.db_input($vars['notes']); diff --git a/include/class.ticket.php b/include/class.ticket.php index 6b933239de4bcc181f82a2b88724789e3cc5454c..37b39bfda98fc70dc8eb3c44e16be66568ff2df4 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2004,10 +2004,28 @@ class Ticket{ $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 ****/ $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 **********/ if($cfg->getMaxOpenTickets()>0 && ($client=$ticket->getClient()) diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php index 6f8cce2c41a1e6acd8f4810b3cdc7e643a9a4471..c84e539b6ade114b0fc87fc36b01c9d40e6c3e30 100644 --- a/include/staff/filter.inc.php +++ b/include/staff/filter.inc.php @@ -181,6 +181,27 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <strong>Disable</strong> auto-response. <em>(Overwrites Dept. settings)</em> </td> </tr> + <tr> + <td width="180"> + Canned Response: + </td> + <td> + <select name="canned_response"> + <option value="">— None —</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> <td width="180"> Department: diff --git a/main.inc.php b/main.inc.php index 5184b250e567ceeb4863018f0fd2e23f116bf348..36f7bf07ffa0fce5e35776974a04521856e7bfee 100644 --- a/main.inc.php +++ b/main.inc.php @@ -60,7 +60,7 @@ #Current version && schema signature (Changes from version to version) 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 $configfile=''; diff --git a/scp/filters.php b/scp/filters.php index f39b794d047a1f4fa756c320346dae26ed8b9623..fbbf923a9c8052db8f12e3eeb6056a9d8b29a4f8 100644 --- a/scp/filters.php +++ b/scp/filters.php @@ -15,6 +15,7 @@ **********************************************************************/ require('admin.inc.php'); include_once(INCLUDE_DIR.'class.filter.php'); +require_once(INCLUDE_DIR.'class.canned.php'); $filter=null; if($_REQUEST['id'] && !($filter=Filter::lookup($_REQUEST['id']))) $errors['err']='Unknown or invalid filter.'; diff --git a/setup/inc/sql/b19dc97d-71e05961.patch.sql b/setup/inc/sql/b19dc97d-71e05961.patch.sql new file mode 100644 index 0000000000000000000000000000000000000000..2dde766255c5257e486ab3082b7762b5aa29a459 --- /dev/null +++ b/setup/inc/sql/b19dc97d-71e05961.patch.sql @@ -0,0 +1,13 @@ +/** + * 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'; diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql index 7f29d024f38ae354614e51a083eec9a148968df7..54b4b5442d6fc9e070582f181c865eced9c4d097 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql +++ b/setup/inc/sql/osticket-v1.7-mysql.sql @@ -237,6 +237,7 @@ CREATE TABLE `%TABLE_PREFIX%email_filter` ( `reject_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', + `canned_response` int(11) unsigned NOT NULL default '0', `email_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', diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 index a1d99aa526afd9af5d19e5bd1d8c98ea7608ab91..b9831f7883f451e0eee1a70de0221f61abd4b983 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 +++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 @@ -1 +1 @@ -b19dc97d19f7a30f59663c812d1f3ddc +71e05961fdb7a993a21704ae513512bc