Source
xxxxxxxxxx
TIMEPERIOD_TYPE_MONTHLY => ['timeperiod_type', 'every', 'month', 'dayofweek', 'day', 'start_time', 'period']
<?php declare(strict_types = 0);
/*
** Zabbix
** 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 General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
class CControllerMaintenanceCreate extends CController {
protected function init(): void {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
}
protected function checkInput(): bool {
$fields = [
'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.'));