Skip to content

Commit

Permalink
Don't allow making tags attributes private
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed May 19, 2017
1 parent 43fdc31 commit e09837e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions application/classes/Ushahidi/Validator/Form/Attribute/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function __construct(FormAttributeRepository $repo, FormStageRepository $

protected function getRules()
{
$input = $this->validation_engine->getFullData('tags');

return [
'key' => [
['max_length', [':value', 150]],
Expand Down Expand Up @@ -76,7 +78,7 @@ protected function getRules()
]]],
],
'required' => [
['in_array', [':value', [true,false]]],
['in_array', [':value', [true, false]]],
],
'priority' => [
['digit'],
Expand All @@ -92,10 +94,13 @@ protected function getRules()
'form_id' => [
['digit'],
],
'response_private' => [
[[$this, 'canMakePrivate'], [':value', $input]]
]
];
}

public function formStageBelongsToForm($value)
public function formStageBelongsToForm($value)
{
// don't check against nonexistant data
if (!$value || !isset($this->valid['form_id'])) {
Expand All @@ -105,4 +110,14 @@ public function formStageBelongsToForm($value)
$group = $this->form_stage_repo->get($value);
return ($group->form_id == $this->valid['form_id']);
}

public function canMakePrivate($value, $input)
{
// If input type is tags, then attribute cannot be private
if ($input === 'tags' && $value !== false) {
return false;
}

return true;
}
}

0 comments on commit e09837e

Please sign in to comment.