<?php declare(strict_types = 0);
class CControllerServiceCreate extends CController {
protected function init(): void {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
protected function checkInput(): bool {
'name' => 'required|db services.name|not_empty',
'parent_serviceids' => 'array_db services.serviceid',
'problem_tags' => 'array',
'sortorder' => 'required|db services.sortorder|ge 0|le 999',
'algorithm' => 'required|db services.algorithm|in '.implode(',', [ZBX_SERVICE_STATUS_CALC_SET_OK, ZBX_SERVICE_STATUS_CALC_MOST_CRITICAL_ALL, ZBX_SERVICE_STATUS_CALC_MOST_CRITICAL_ONE]),
'description' => 'db services.description',
'status_rules' => 'array',
'propagation_rule' => 'db services.propagation_rule|in '.implode(',', array_keys(CServiceHelper::getStatusPropagationNames())),
'propagation_value_number' => 'int32',
'propagation_value_status' => 'int32',
'weight' => 'required|db services.weight|ge 0|le 1000000',
'child_serviceids' => 'array_db services.serviceid'
$ret = $this->validateInput($fields);
switch ($this->getInput('propagation_rule')) {
case ZBX_SERVICE_STATUS_PROPAGATION_INCREASE:
case ZBX_SERVICE_STATUS_PROPAGATION_DECREASE:
$fields['propagation_value_number'] = 'required|ge 1|le '.(TRIGGER_SEVERITY_COUNT - 1);
case ZBX_SERVICE_STATUS_PROPAGATION_FIXED:
$fields['propagation_value_status'] =
'required|in '.implode(',', array_keys(CServiceHelper::getStatusNames()));
$validator = new CNewValidator(array_intersect_key($this->getInputAll(), $fields), $fields);
foreach ($validator->getAllErrors() as $error) {