Source
xxxxxxxxxx
TIMEPERIOD_TYPE_MONTHLY => ['timeperiod_type', 'every', 'month', 'dayofweek', 'day', 'start_time', 'period']
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
class CControllerMaintenanceUpdate extends CController {
protected function init(): void {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
}
protected function checkInput(): bool {
$fields = [
'maintenanceid' => 'required|id',
'name' => 'required|string|not_empty',
'maintenance_type' => 'required|in '.implode(',', [MAINTENANCE_TYPE_NORMAL, MAINTENANCE_TYPE_NODATA]),
'active_since' => 'required|abs_time',
'active_till' => 'required|abs_time',
'timeperiods' => 'required|array',
'groupids' => 'array_id',
'hostids' => 'array_id',
'tags_evaltype' => 'in '.implode(',', [MAINTENANCE_TAG_EVAL_TYPE_AND_OR, MAINTENANCE_TAG_EVAL_TYPE_OR]),
'tags' => 'array',
'description' => 'required|string'
];
$ret = $this->validateInput($fields);
if ($ret) {
if ($this->getInput('maintenance_type') == MAINTENANCE_TYPE_NORMAL) {
$fields = [
'tags_evaltype' => 'required'
];
$validator = new CNewValidator(array_intersect_key($this->getInputAll(), $fields), $fields);
foreach ($validator->getAllErrors() as $error) {
error($error);
}
if ($validator->isErrorFatal() || $validator->isError()) {
$ret = false;
}
}
if (!$this->hasInput('groupids') && !$this->hasInput('hostids')) {
error(_('At least one host group or host must be selected.'));
$ret = false;
}
}