Source
'selectMedias' => ['mediaid', 'mediatypeid', 'period', 'sendto', 'severity', 'active', 'provisioned'],
<?php
/*
** 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 containing operations with user profile notification edit form.
*/
class CControllerUserProfileNotificationEdit extends CControllerUserEditGeneral {
protected function checkInput(): bool {
$fields = [
'messages' => 'array',
'form_refresh' => 'int32'
];
if (CWebUser::$data['type'] > USER_TYPE_ZABBIX_USER) {
$fields += [
'medias' => 'array'
];
}
$ret = $this->validateInput($fields) && $this->validateMedias();
if (!$ret) {
$this->setResponse(new CControllerResponseFatal());
}
return $ret;
}
protected function validateMedias(): bool {
$validation_rules = [
'mediaid' => 'id',
'mediatypeid' => 'required|db media_type.mediatypeid',
'sendto' => 'required',
'period' => 'required|time_periods',
'active' => 'in '.implode(',', [MEDIA_STATUS_ACTIVE, MEDIA_STATUS_DISABLED]),
'severity' => 'int32|ge 0|le '.(pow(2, TRIGGER_SEVERITY_COUNT) - 1)
];
foreach ($this->getInput('medias', []) as $media) {
$validator = new CNewValidator($media, $validation_rules);
if ($validator->isError()) {
return false;
}
}
return true;
}