$misc = $this->getModule('misc');
$limit = $this->Request->contains('limit') && $misc->isValidInteger($this->Request['limit']) ? (int)$this->Request['limit'] : 0;
$offset = $this->Request->contains('offset') && $misc->isValidInteger($this->Request['offset']) ? (int)$this->Request['offset'] : 0;
+ $jobtype = $this->Request->contains('type') && $misc->areValidJobTypes($this->Request['type']) ? $this->Request['type'] : null;
$objecttype = $this->Request->contains('objecttype') && $misc->isValidName($this->Request['objecttype']) ? $this->Request['objecttype'] : null;
$objectname = $this->Request->contains('objectname') && $misc->isValidNameExt($this->Request['objectname']) ? $this->Request['objectname'] : null;
$objectcategory = $this->Request->contains('objectcategory') && $misc->isValidName($this->Request['objectcategory']) ? $this->Request['objectcategory'] : null;
'vals' => $objectstatus
];
}
+ if (!empty($jobtype)) {
+ $general_params['Job.Type'] = [];
+ $general_params['Job.Type'][] = [
+ 'operator' => 'IN',
+ 'vals' => str_split($jobtype),
+ ];
+ }
if (!empty($jobname)) {
$general_params['Job.Name'] = [];
$general_params['Job.Name'][] = [
return key_exists($job_type, $this->job_types);
}
+ /**
+ * Validate more than one job type.
+ *
+ * @param string $job_types job types ex. 'BCg'
+ * @return true if all provided job types are valid, otherwise false
+ */
+ public function areValidJobTypes($job_types) {
+ $types = str_split($job_types);
+ $valid = true;
+ for ($i = 0; $i < count($types); $i++) {
+ if (!$this->isValidJobType($types[$i])) {
+ $valid = false;
+ break;
+ }
+ }
+ return $valid;
+ }
+
public function isValidName($name) {
return (preg_match('/^[\w:\.\-\s]{1,127}$/', $name) === 1);
}