Skip to content
Snippets Groups Projects
Unverified Commit 10ad2ef2 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #4513 from aydreeihn/issue/filter-action-validations

Filter Action Validation Fixes
parents f82d41a1 3d45adc5
No related branches found
No related tags found
No related merge requests found
......@@ -149,6 +149,7 @@ class Filter {
else
$this->ht['flags'] &= ~$flag;
$vars['rules']= $this->getRules();
$this->ht['pass'] = true;
$this->update($this->ht, $errors);
}
......@@ -538,6 +539,10 @@ class Filter {
}
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']))
return;
......@@ -569,26 +574,29 @@ class Filter {
}
}
switch ($action->ht['type']) {
case 'dept':
$dept = Dept::lookup($config['dept_id']);
if (!$dept || !$dept->isActive()) {
$errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Department');
}
break;
case 'topic':
$topic = Topic::lookup($config['topic_id']);
if (!$topic || !$topic->isActive()) {
$errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Help Topic');
}
break;
default:
foreach ($config as $key => $value) {
if (!$value) {
$errors['err'] = sprintf(__('Unable to save: Please insert a value for %s'), ucfirst($action->ht['type']));
}
// do not throw an error if we are deleting an action
if (substr($v, 0, 1) != 'D') {
switch ($action->ht['type']) {
case 'dept':
$dept = Dept::lookup($config['dept_id']);
if (!$dept || !$dept->isActive()) {
$errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Department');
}
break;
case 'topic':
$topic = Topic::lookup($config['topic_id']);
if (!$topic || !$topic->isActive()) {
$errors['err'] = sprintf(__('Unable to save: Please choose an active %s'), 'Help Topic');
}
break;
default:
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.
Finish editing this message first!
Please register or to comment