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

Change Filter.target from "All" to "Any"

Force target selection on filter form
Add minor code improvements
parent b24f18d9
No related branches found
No related tags found
No related merge requests found
......@@ -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'],
......@@ -289,7 +289,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'];
......@@ -342,10 +342,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 +430,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 +717,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 +746,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 +755,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 +776,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 +789,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'":"")
......
......@@ -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"':''; ?>>&mdash; Applies to ALL Tickets &dash;</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="">&mdash; Select a Target &dash;</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>
&nbsp;
<span class="error">&nbsp;<?php echo $errors['target']; ?></span>
<span class="error">*&nbsp;<?php echo $errors['target']; ?></span>
</td>
</tr>
<tr>
......
......@@ -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`;
......
/**
* @version v1.7 RC3
* @signature fa8bd41a6fbee9f2bd97c59f4d0778ba
* @signature 1da1bcbafcedc65efef58f142a48ac91
*
* Upgrade from 1.6 RC3 + filters
*
......@@ -13,9 +13,9 @@ 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` );
-- Finished with patch
UPDATE `%TABLE_PREFIX%config`
SET `schema_signature`='fa8bd41a6fbee9f2bd97c59f4d0778ba';
SET `schema_signature`='1da1bcbafcedc65efef58f142a48ac91';
......@@ -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
......
......@@ -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,
......
fa8bd41a6fbee9f2bd97c59f4d0778ba
1da1bcbafcedc65efef58f142a48ac91
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment