change name Validation priorities

This commit is contained in:
Guillermo 2019-12-17 15:25:45 -03:00
parent 870f5fea46
commit 61ce46d5c7
4 changed files with 26 additions and 8 deletions

View File

@ -71,7 +71,7 @@ class SearchController extends Controller {
'error' => ERRORS::INVALID_UNREAD_STAFF_FILTER 'error' => ERRORS::INVALID_UNREAD_STAFF_FILTER
], ],
'priority' => [ 'priority' => [
'validation' => DataValidator::oneOf(DataValidator::validPrioritys(),DataValidator::nullType()), 'validation' => DataValidator::oneOf(DataValidator::validPriorities(),DataValidator::nullType()),
'error' => ERRORS::INVALID_PRIORITY_FILTER 'error' => ERRORS::INVALID_PRIORITY_FILTER
], ],
'dateRange' => [ 'dateRange' => [
@ -205,11 +205,11 @@ class SearchController extends Controller {
$filters .= "ticket.unread_staff = " . $unreadStaff; $filters .= "ticket.unread_staff = " . $unreadStaff;
} }
} }
private function setPriorityFilter($prioritys, &$filters){ private function setPriorityFilter($priorities, &$filters){
if($prioritys != null){ if($priorities != null){
$first = TRUE; $first = TRUE;
if ($filters != "") $filters .= " and "; if ($filters != "") $filters .= " and ";
foreach(array_unique($prioritys) as $priority) { foreach(array_unique($priorities) as $priority) {
if($first){ if($first){
$filters .= " ( "; $filters .= " ( ";
@ -228,7 +228,7 @@ class SearchController extends Controller {
} }
$prioritys != "" ? $filters .= ") " : null; $priorities != "" ? $filters .= ") " : null;
} }
} }

View File

@ -0,0 +1,19 @@
<?php
namespace CustomValidations;
use Respect\Validation\Rules\AbstractRule;
class ValidPriorities extends AbstractRule {
public function validate($prioritys) {
$PriorityList = json_decode($prioritys);
if(is_array($PriorityList)){
foreach (array_unique($PriorityList) as $priorityId) {
if($priorityId != 0 && $priorityId != 1 && $priorityId != 2) return false;
}
return true;
}
return false;
}
}

View File

@ -22,11 +22,10 @@ require './user/send-recover-password.rb'
require './user/recover-password.rb' require './user/recover-password.rb'
require './user/edit-password.rb' require './user/edit-password.rb'
require './user/edit-email.rb' require './user/edit-email.rb'
#require './ticket/search.rb'
require './user/get.rb' require './user/get.rb'
require './user/enable-disable.rb' require './user/enable-disable.rb'
require './ticket/seen.rb'
require './ticket/create.rb' require './ticket/create.rb'
require './ticket/seen.rb'
require './ticket/comment.rb' require './ticket/comment.rb'
require './ticket/get.rb' require './ticket/get.rb'
require './ticket/custom-response.rb' require './ticket/custom-response.rb'

View File

@ -1,7 +1,7 @@
describe '/system/get-settings' do describe '/system/get-settings' do
it 'should return correct values' do it 'should return correct values' do
result = request('/system/get-settings') result = request('/system/get-settings')
(result['status']).should.equal('success') (result['status']).should.equal('success')
(result['data']['language']).should.equal('en') (result['data']['language']).should.equal('en')
(result['data']['departments'][0]['name']).should.equal('Help and Support') (result['data']['departments'][0]['name']).should.equal('Help and Support')