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

Filter Action Validation Fixes

- Let validate_actions pass if we are trying to disable/archive a Help Topic so that the filter flag can be set.
- Make sure we do not throw validation errors when deleting a filter action. Just delete it.
parent eb1f76a8
Branches
Tags
No related merge requests found
...@@ -149,6 +149,7 @@ class Filter { ...@@ -149,6 +149,7 @@ class Filter {
else else
$this->ht['flags'] &= ~$flag; $this->ht['flags'] &= ~$flag;
$vars['rules']= $this->getRules(); $vars['rules']= $this->getRules();
$this->ht['pass'] = true;
$this->update($this->ht, $errors); $this->update($this->ht, $errors);
} }
...@@ -538,6 +539,10 @@ class Filter { ...@@ -538,6 +539,10 @@ class Filter {
} }
function validate_actions($vars, &$errors) { function validate_actions($vars, &$errors) {
//allow the save if it is to set a filter flag
if ($vars['pass'])
return true;
if (!is_array(@$vars['actions'])) if (!is_array(@$vars['actions']))
return; return;
...@@ -569,26 +574,29 @@ class Filter { ...@@ -569,26 +574,29 @@ class Filter {
} }
} }
switch ($action->ht['type']) { // do not throw an error if we are deleting an action
case 'dept': if (substr($v, 0, 1) != 'D') {
$dept = Dept::lookup($config['dept_id']); switch ($action->ht['type']) {
if (!$dept || !$dept->isActive()) { case 'dept':
$errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Department'); $dept = Dept::lookup($config['dept_id']);
} if (!$dept || !$dept->isActive()) {
break; $errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Department');
case 'topic': }
$topic = Topic::lookup($config['topic_id']); break;
if (!$topic || !$topic->isActive()) { case 'topic':
$errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Help Topic'); $topic = Topic::lookup($config['topic_id']);
} if (!$topic || !$topic->isActive()) {
break; $errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Help Topic');
default: }
foreach ($config as $key => $value) { break;
if (!$value) { default:
$errors['err'] = sprintf(__('Unable to save: Please insert a value for %s'), ucfirst($action->ht['type'])); foreach ($config as $key => $value) {
} if (!$value) {
$errors['err'] = sprintf(__('Unable to save: Please insert a value for %s'), ucfirst($action->ht['type']));
}
}
break;
} }
break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment