Source
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
use CController as CAction;
class CLegacyAction extends CAction {
protected function init(): void {
$this->disableCsrfValidation();
}
public function doAction(): void {
}
/**
* Check user input.
*
* @return bool
*/
public function checkInput(): bool {
$json_actions = ['templates.php', 'host_prototypes.php'];
if (in_array($this->getAction(), $json_actions) && array_key_exists('formdata_json', $_REQUEST)) {
$_REQUEST = json_decode($_REQUEST['formdata_json'], true);
}
return true;
}
/**
* Check permission.
*
* @return bool
*/
public function checkPermissions(): bool {
$user_type = $this->getUserType();
$denied = [];
$action = $this->getAction();
/*
* Overwrite legacy action in case user is located in sub-section like items, triggers etc. That will make
* sure to hide left menu and display error in case user has no access to templates or hosts.
*/
if (in_array(getRequest('context', ''), ['host', 'template']) && in_array($action, ['items.php', 'triggers.php',
'graphs.php', 'host_discovery.php', 'httpconf.php', 'disc_prototypes.php', 'trigger_prototypes.php',