diff --git a/include/class.filter.php b/include/class.filter.php index 9c3065c10aba5aa1e359e4c36a67e4de83aec9fe..a749e5eaeabc6c08d0a44d29fa30782511313bac 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_id']; + } + 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['cannedResponseId'] = $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_id='.db_input($vars['canned_response']). ',notes='.db_input($vars['notes']); diff --git a/include/class.ticket.php b/include/class.ticket.php index 80b6a60ac4a2b989fddb2fb3ced7ab6e98a7d7ad..0d9a8ced06a145b71f218af47be20c58fbfa27a1 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2003,10 +2003,28 @@ class Ticket{ $autorespond=false; } + // If a canned-response is immediately queued for this ticket, + // disable the autoresponse + if ($vars['cannedResponseId']) + $autorespond=false; + /***** See if we need to send some alerts ****/ $ticket->onNewTicket($vars['message'], $autorespond, $alertstaff); + if ($vars['cannedResponseId'] + && ($canned = Canned::lookup($vars['cannedResponseId']))) { + $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..b23dd520bc8338ba4188162395f3045df6aaef3f 100644 --- a/include/staff/filter.inc.php +++ b/include/staff/filter.inc.php @@ -181,6 +181,29 @@ $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 + $sql='SELECT canned_id,title FROM '.CANNED_TABLE.' ORDER by title'; + if ($res=db_query($sql)) { + while (list($id,$title)=db_fetch_row($res)) { + $selected=($info['canned_response'] && + $id==$info['canned_response']) + ? 'selected="selected"' : ''; + echo sprintf('<option value="%d" %s>%s</option>', + $id, $selected, $title); + } + } + ?> + </select> + <em>(Automatically respond with this canned attachment)</em> + </td> + </tr> <tr> <td width="180"> Department: diff --git a/include/upgrader/patches/b19dc97d-435c62c3.patch.sql b/include/upgrader/patches/b19dc97d-435c62c3.patch.sql new file mode 100644 index 0000000000000000000000000000000000000000..b908348a728445778725b9215eebe432e270e9dc --- /dev/null +++ b/include/upgrader/patches/b19dc97d-435c62c3.patch.sql @@ -0,0 +1,16 @@ +/** + * Support canned response definition for email filters + * + * @version 1.7-rc1 canned-response-in-filter + */ + +ALTER TABLE `%TABLE_PREFIX%email_filter` + ADD `canned_response_id` int(11) unsigned NOT NULL default '0' + AFTER `disable_autoresponder`; + +-- Add index for linking responses to messages quickly +ALTER TABLE `%TABLE_PREFIX%ticket_thread` ADD KEY `pid` (`pid`); + +-- Finished with patch +UPDATE `%TABLE_PREFIX%config` + SET `schema_signature`='435c62c3b23795529bcfae7e7371d82e'; diff --git a/main.inc.php b/main.inc.php index d4d44fde7d72738d3b4e404f1e713b3e0ae9f01d..1de9c91a3185d6a740cf9832069be71c0a29a805 100644 --- a/main.inc.php +++ b/main.inc.php @@ -63,7 +63,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','435c62c3b23795529bcfae7e7371d82e'); //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/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql index 7f29d024f38ae354614e51a083eec9a148968df7..ed6ea688e34b1e00a2adb0cbebdfe22a02e6f3d1 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_id` 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', @@ -659,6 +660,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_thread` ( PRIMARY KEY (`id`), KEY `ticket_id` (`ticket_id`), KEY `staff_id` (`staff_id`), + KEY `pid` (`pid`), FULLTEXT KEY `body` (`body`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 index a1d99aa526afd9af5d19e5bd1d8c98ea7608ab91..c3f03508703f6860c9628810c3b59ef8af0ce864 100644 --- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 +++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5 @@ -1 +1 @@ -b19dc97d19f7a30f59663c812d1f3ddc +435c62c3b23795529bcfae7e7371d82e