Source
$this->getInputs($data, ['username', 'name', 'surname', 'change_password', 'password1', 'password2', 'lang',
<?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 edit form.
*/
class CControllerUserEdit extends CControllerUserEditGeneral {
protected function checkInput() {
$locales = array_keys(getLocales());
$locales[] = LANG_DEFAULT;
$themes = array_keys(APP::getThemes());
$themes[] = THEME_DEFAULT;
$fields = [
'userid' => 'db users.userid',
'username' => 'db users.username',
'name' => 'db users.name',
'surname' => 'db users.surname',
'user_groups' => 'array_id',
'change_password' => 'in 1',
'current_password' => 'string',
'password1' => 'string',
'password2' => 'string',
'lang' => 'db users.lang|in '.implode(',', $locales),
'timezone' => 'db users.timezone|in '.implode(',', array_keys($this->timezones)),
'theme' => 'db users.theme|in '.implode(',', $themes),
'autologin' => 'db users.autologin|in 0,1',
'autologout' => 'db users.autologout',
'refresh' => 'db users.refresh',
'rows_per_page' => 'db users.rows_per_page',
'url' => 'db users.url',
'medias' => 'array',
'new_media' => 'array',
'enable_media' => 'int32',
'disable_media' => 'int32',
'roleid' => 'id',
'form_refresh' => 'int32'
];
$ret = $this->validateInput($fields);
if (!$ret) {
$this->setResponse(new CControllerResponseFatal());
}
return $ret;
}
protected function checkPermissions(): bool {
if (!$this->checkAccess(CRoleHelper::UI_ADMINISTRATION_USERS)) {
return false;
}
if ($this->getInput('userid', 0) != 0) {
$users = API::User()->get([
'output' => ['username', 'name', 'surname', 'lang', 'theme', 'autologin', 'autologout', 'refresh',
'rows_per_page', 'url', 'roleid', 'timezone', 'provisioned'
],
'selectMedias' => ['mediaid', 'mediatypeid', 'period', 'sendto', 'severity', 'active',
'provisioned'
],
'selectRole' => ['roleid'],
'selectUsrgrps' => ['usrgrpid'],
'userids' => $this->getInput('userid'),
'editable' => true
]);
if (!$users) {
return false;
}
$this->user = $users[0];
}
return true;
}