diff --git a/include/class.canned.php b/include/class.canned.php index 0bdc492a463b97604e35a9e58b7861e42ce61dcd..c84950e7d6d19b062dbb3a53c0ccfe95eab96c48 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -36,7 +36,7 @@ class Canned { .' FROM '.CANNED_TABLE.' canned ' .' LEFT JOIN '.CANNED_ATTACHMENT_TABLE.' attach ON (attach.canned_id=canned.canned_id) ' .' LEFT JOIN '.FILTER_TABLE.' filter ON (canned.canned_id = filter.canned_response_id) ' - .' WHERE canned.canned_id='.db_input($id); + .' WHERE canned.canned_id='.db_input($id) .' GROUP BY canned.canned_id'; if(!($res=db_query($sql)) || !db_num_rows($res)) diff --git a/include/class.filter.php b/include/class.filter.php index ea191c1a402941ee744c1fe7c1a798e328457b96..ce7d7d92cb273705bc458e32e6c7dd93cf8668e7 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -226,7 +226,7 @@ class Filter { */ function matches($info) { - if(!$info) return false; + if(!$info || !is_array($info)) return false; $what = array( 'email' => $info['email'], @@ -246,7 +246,9 @@ class Filter { $match = false; # Respect configured filter email-id - if ($this->getEmailId() && $this->getEmailId() != $info['emailId']) + if ($this->getEmailId() + && !strcasecmp($this->getTarget(), 'Email') + && $this->getEmailId() != $info['emailId']) return false; foreach ($this->getRules() as $rule) { @@ -289,7 +291,7 @@ class Filter { # XXX: Unset the other (of staffId or teamId) (?) if ($this->getStaffId()) $ticket['staffId']=$this->getStaffId(); elseif ($this->getTeamId()) $ticket['teamId']=$this->getTeamId(); - # Override name with reply-to information from the TcicketFilter + # Override name with reply-to information from the TicketFilter # match if ($this->useReplyToEmail() && $info['reply-to']) { $ticket['email'] = $info['reply-to']; @@ -303,10 +305,10 @@ class Filter { } /* static */ function getSupportedMatches() { return array( - 'name'=> "Sender's Name", - 'email'=> "Sender's Email", - 'subject'=> 'Email Subject', - 'body'=> 'Email Body/Text' + 'name'=> 'Name', + 'email'=> 'Email', + 'subject'=> 'Subject', + 'body'=> 'Body/Text' ); } /* static */ function getSupportedMatchTypes() { @@ -342,10 +344,10 @@ class Filter { /** static functions **/ function getTargets() { return array( - 'All' => 'All', + 'Any' => 'Any', 'Web' => 'Web Forms', - 'Email' => 'Emails', - 'API' => 'API Calls'); + 'API' => 'API Calls', + 'Email' => 'Emails'); } function create($vars,&$errors) { @@ -430,7 +432,10 @@ class Filter { if(!$errors && !self::validate_rules($vars,$errors) && !$errors['rules']) $errors['rules'] = 'Unable to validate rules as entered'; - if(!is_numeric($vars['target']) && !in_array($vars['target'], array('All', 'Email', 'Web'))) + $targets = self::getTargets(); + if(!$vars['target']) + $errors['target'] = 'Target required'; + else if(!is_numeric($vars['target']) && !$targets[$vars['target']]) $errors['target'] = 'Unknown or invalid target'; if($errors) return false; @@ -714,7 +719,7 @@ class TicketFilter { $sql='SELECT id FROM '.FILTER_TABLE .' WHERE isactive=1 ' - .' AND (target="All" OR target='.db_input($this->getTarget()).') ' + .' AND target IN ("Any", '.db_input($this->getTarget()).') ' .' ORDER BY execorder'; return db_query($sql); @@ -743,7 +748,7 @@ class TicketFilter { * information from the database. Whether the filter will completely * match or not is determined in the Filter::matches() method. */ - /* static */ function quickList() { + function quickList() { if(!$this->vars || !$this->vars['email']) return $this->getAllActive(); @@ -752,7 +757,7 @@ class TicketFilter { .' INNER JOIN '.FILTER_TABLE.' filter ' .' ON (filter.id=rule.filter_id) ' .' WHERE filter.isactive ' - ." AND (filter.target='All' OR filter.target=".db_input($this->getTarget()).') '; + ." AND filter.target IN ('Any', ".db_input($this->getTarget()).') '; # Filter by system's email-id if specified if($this->vars['emailId']) @@ -773,7 +778,7 @@ class TicketFilter { ." INNER JOIN ".FILTER_TABLE." filter" ." ON (rule.filter_id=filter.id)" ." WHERE filter.isactive" - ." AND (filter.target='All' OR filter.target=".db_input($this->getTarget()).")" + ." AND filter.target IN('Any', ".db_input($this->getTarget()).")" ." GROUP BY filter_id" ." HAVING COUNT(*)-COUNT(NULLIF(what,'email'))=0"; if (!$this->vars['name']) $sql.=" AND COUNT(*)-COUNT(NULLIF(what,'name'))=0"; @@ -786,7 +791,7 @@ class TicketFilter { ." INNER JOIN ".FILTER_TABLE." filter" ." ON (rule.filter_id=filter.id)" ." WHERE filter.isactive" - ." AND (filter.target='All' OR filter.target=".db_input($this->getTarget()).")" + ." AND filter.target IN ('Any', ".db_input($this->getTarget()).")" ." AND what NOT IN ('email'" # Handle sender-name and subject if specified .((!$this->vars['name'])?",'name'":"") diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php index 346fc6a8677fd108b9438635a48c967e0b2f764f..36186838bd93cdba6977add500645becba4d673e 100644 --- a/include/staff/filter.inc.php +++ b/include/staff/filter.inc.php @@ -76,14 +76,15 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </td> <td> <select name="target"> - <option value="All" <?php echo ($info['target']=='All')?'selected="selected"':''; ?>>— Applies to ALL Tickets ‐</option> - <option value="Web" <?php echo ($info['target']=='Web')?'selected="selected"':''; ?>>Web Forms</option> - <option value="API" <?php echo ($info['target']=='API')?'selected="selected"':''; ?>>API Calls</option> - <option value="Email" <?php echo ($info['target']=='Email')?'selected="selected"':''; ?>>Emails</option> - <?php + <option value="">— Select a Target ‐</option> + <?php + foreach(Filter::getTargets() as $k => $v) { + echo sprintf('<option value="%s" %s>%s</option>', + $k, (($k==$info['target'])?'selected="selected"':''), $v); + } $sql='SELECT email_id,email,name FROM '.EMAIL_TABLE.' email ORDER by name'; if(($res=db_query($sql)) && db_num_rows($res)) { - echo '<OPTGROUP label="Specific Incoming Emails">'; + echo '<OPTGROUP label="Specific System Email">'; while(list($id,$email,$name)=db_fetch_row($res)) { $selected=($info['email_id'] && $id==$info['email_id'])?'selected="selected"':''; if($name) @@ -95,7 +96,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ?> </select> - <span class="error"> <?php echo $errors['target']; ?></span> + <span class="error">* <?php echo $errors['target']; ?></span> </td> </tr> <tr> diff --git a/include/upgrader/sql/c00511c7-7be60a84.patch.sql b/include/upgrader/sql/c00511c7-7be60a84.patch.sql index 638248b976019a670c773578b564d99a3daacc6a..fdefd09bea960de619fc5a1feac8bd69d3c77b8e 100644 --- a/include/upgrader/sql/c00511c7-7be60a84.patch.sql +++ b/include/upgrader/sql/c00511c7-7be60a84.patch.sql @@ -63,7 +63,7 @@ ALTER TABLE `%TABLE_PREFIX%config` ADD `transfer_alert_dept_manager` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `transfer_alert_assigned` , ADD `transfer_alert_dept_members` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `transfer_alert_dept_manager`, ADD `send_sys_errors` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `enable_email_piping`, - ADD `enable_kb` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `use_email_priority`, + ADD `enable_kb` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `use_email_priority`, ADD `enable_premade` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `enable_kb`, ADD `show_related_tickets` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `auto_assign_reopened_tickets`, ADD `schema_signature` CHAR( 32 ) NOT NULL AFTER `ostversion`; diff --git a/include/upgrader/sql/d0e37dca-fa8bd41a.patch.sql b/include/upgrader/sql/d0e37dca-1da1bcba.patch.sql similarity index 61% rename from include/upgrader/sql/d0e37dca-fa8bd41a.patch.sql rename to include/upgrader/sql/d0e37dca-1da1bcba.patch.sql index 1dc4636856bfd7a15f033d91cce5f0b92bc62625..3d3bda68e2fd49293e1a73545506416c7a1cc126 100644 --- a/include/upgrader/sql/d0e37dca-fa8bd41a.patch.sql +++ b/include/upgrader/sql/d0e37dca-1da1bcba.patch.sql @@ -1,6 +1,6 @@ /** * @version v1.7 RC3 - * @signature fa8bd41a6fbee9f2bd97c59f4d0778ba + * @signature 1da1bcbafcedc65efef58f142a48ac91 * * Upgrade from 1.6 RC3 + filters * @@ -13,9 +13,11 @@ RENAME TABLE `%TABLE_PREFIX%email_filter_rule` TO `%TABLE_PREFIX%filter_rule`; ALTER TABLE `%TABLE_PREFIX%filter` CHANGE `reject_email` `reject_ticket` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'; ALTER TABLE `%TABLE_PREFIX%filter` - ADD `target` ENUM( 'All', 'Web', 'Email', 'API' ) NOT NULL DEFAULT 'All' AFTER `sla_id` , + ADD `target` ENUM( 'Any', 'Web', 'Email', 'API' ) NOT NULL DEFAULT 'Any' AFTER `sla_id` , ADD INDEX ( `target` ); +UPDATE `%TABLE_PREFIX%filter` SET `target` = 'Email' WHERE `email_id` != 0; + -- Finished with patch UPDATE `%TABLE_PREFIX%config` - SET `schema_signature`='fa8bd41a6fbee9f2bd97c59f4d0778ba'; + SET `schema_signature`='1da1bcbafcedc65efef58f142a48ac91'; diff --git a/main.inc.php b/main.inc.php index f737c361b307e4c139cab68c396c04fc72f66339..c3986f80922687722184fc90df9bfeb150f5fb71 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-RC2'); //Shown on admin panel - define('SCHEMA_SIGNATURE','fa8bd41a6fbee9f2bd97c59f4d0778ba'); //MD5 signature of the db schema. (used to trigger upgrades) + define('SCHEMA_SIGNATURE','1da1bcbafcedc65efef58f142a48ac91'); //MD5 signature of the db schema. (used to trigger upgrades) #load config info $configfile=''; if(file_exists(ROOT_DIR.'ostconfig.php')) //Old installs prior to v 1.6 RC5 diff --git a/setup/inc/sql/osTicket-mysql.sql b/setup/inc/sql/osTicket-mysql.sql index fa183d9642fbb85d07b06b0b35f2699820fc9da8..6be37af6d3ebdc802140748fc4c4b8b03b333796 100644 --- a/setup/inc/sql/osTicket-mysql.sql +++ b/setup/inc/sql/osTicket-mysql.sql @@ -91,7 +91,7 @@ CREATE TABLE `%TABLE_PREFIX%config` ( `clickable_urls` tinyint(1) unsigned NOT NULL default '1', `allow_priority_change` tinyint(1) unsigned NOT NULL default '0', `use_email_priority` tinyint(1) unsigned NOT NULL default '0', - `enable_kb` tinyint(1) unsigned NOT NULL default '1', + `enable_kb` tinyint(1) unsigned NOT NULL default '0', `enable_premade` tinyint(1) unsigned NOT NULL default '1', `enable_captcha` tinyint(1) unsigned NOT NULL default '0', `enable_auto_cron` tinyint(1) unsigned NOT NULL default '0', @@ -245,7 +245,7 @@ CREATE TABLE `%TABLE_PREFIX%filter` ( `staff_id` int(10) unsigned NOT NULL default '0', `team_id` int(10) unsigned NOT NULL default '0', `sla_id` int(10) unsigned NOT NULL default '0', - `target` ENUM( 'All', 'Web', 'Email', 'API' ) NOT NULL DEFAULT 'All', + `target` ENUM( 'Any', 'Web', 'Email', 'API' ) NOT NULL DEFAULT 'Any', `name` varchar(32) NOT NULL default '', `notes` text, `created` datetime NOT NULL, diff --git a/setup/inc/sql/osTicket-mysql.sql.md5 b/setup/inc/sql/osTicket-mysql.sql.md5 index 24d771c4fa3b9d774d7729f123f4046cf8d2e25a..29a60022fd9f87dda3a08126c338d76ae84bbef8 100644 --- a/setup/inc/sql/osTicket-mysql.sql.md5 +++ b/setup/inc/sql/osTicket-mysql.sql.md5 @@ -1 +1 @@ -fa8bd41a6fbee9f2bd97c59f4d0778ba +1da1bcbafcedc65efef58f142a48ac91