Skip to content
Snippets Groups Projects
Commit bd22f931 authored by aydreeihn's avatar aydreeihn
Browse files

Issue: Filters

- Make sure we only set Filter Flags if they need to be changed (don't update them every time we save)
- Make sure we sure we use the email_id if we have actually set it. Otherwise, we lose what should be set for the Target Channel
parent 2fd4a421
No related branches found
No related tags found
No related merge requests found
...@@ -153,6 +153,10 @@ class Filter { ...@@ -153,6 +153,10 @@ class Filter {
$this->update($this->ht, $errors); $this->update($this->ht, $errors);
} }
function hasFlag($flag) {
return 0 !== ($this->ht['flags'] & $flag);
}
function stopOnMatch() { function stopOnMatch() {
return ($this->ht['stop_onmatch']); return ($this->ht['stop_onmatch']);
} }
...@@ -504,6 +508,10 @@ class Filter { ...@@ -504,6 +508,10 @@ class Filter {
$vars['target'] = 'Email'; $vars['target'] = 'Email';
} }
//Note: this will be set when validating filters
if ($vars['email_id'])
$emailId = $vars['email_id'];
$sql=' updated=NOW() ' $sql=' updated=NOW() '
.',isactive='.db_input($vars['isactive']) .',isactive='.db_input($vars['isactive'])
.',flags='.db_input($vars['flags']) .',flags='.db_input($vars['flags'])
......
...@@ -82,10 +82,10 @@ class FilterAction extends VerySimpleModel { ...@@ -82,10 +82,10 @@ class FilterAction extends VerySimpleModel {
function setFilterFlag($actions, $flag, $bool) { function setFilterFlag($actions, $flag, $bool) {
foreach ($actions as $action) { foreach ($actions as $action) {
$filter = Filter::lookup($action->filter_id); $filter = Filter::lookup($action->filter_id);
if ($filter) { if ($filter && ($flag == 'dept') && ($filter->hasFlag(Filter::FLAG_INACTIVE_DEPT) != $bool))
if ($flag == 'dept') $filter->setFlag(Filter::FLAG_INACTIVE_DEPT, $bool); $filter->setFlag(Filter::FLAG_INACTIVE_DEPT, $bool);
if ($flag == 'topic') $filter->setFlag(Filter::FLAG_INACTIVE_HT, $bool); if ($filter && ($flag == 'topic') && ($filter->hasFlag(Filter::FLAG_INACTIVE_HT) != $bool))
} $filter->setFlag(Filter::FLAG_INACTIVE_HT, $bool);
} }
} }
......
...@@ -31,8 +31,6 @@ if($_POST){ ...@@ -31,8 +31,6 @@ if($_POST){
if(!$filter){ if(!$filter){
$errors['err']=sprintf(__('%s: Unknown or invalid'), __('ticket filter')); $errors['err']=sprintf(__('%s: Unknown or invalid'), __('ticket filter'));
}elseif($filter->update($_POST,$errors)){ }elseif($filter->update($_POST,$errors)){
$filter->setFlag(Filter::FLAG_INACTIVE_DEPT, false);
$filter->setFlag(Filter::FLAG_INACTIVE_HT, false);
$msg=sprintf(__('Successfully updated %s.'), __('this ticket filter')); $msg=sprintf(__('Successfully updated %s.'), __('this ticket filter'));
}elseif(!$errors['err']){ }elseif(!$errors['err']){
$errors['err']=sprintf('%s %s', $errors['err']=sprintf('%s %s',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment