<?php declare(strict_types = 0);
class CControllerGraphList extends CController {
protected function init(): void {
$this->disableCsrfValidation();
protected function checkInput(): bool {
'context' => 'required|in '.implode(',', ['host', 'template']),
'filter_groupids' => 'array_db hosts_groups.groupid',
'filter_hostids' => 'array_db hosts.hostid',
'sort' => 'in '.implode(',', ['graphtype', 'name']),
'sortorder' => 'in '.implode(',', [ZBX_SORT_UP, ZBX_SORT_DOWN]),
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions(): bool {
return $this->getInput('context') === 'host'
? $this->checkAccess(CRoleHelper::UI_CONFIGURATION_HOSTS)
: $this->checkAccess(CRoleHelper::UI_CONFIGURATION_TEMPLATES);
protected function doAction(): void {
$context = $this->getInput('context');
$prefix = $context === 'host' ? 'web.hosts.' : 'web.templates.';
$sort_field = $this->getInput('sort', CProfile::get($prefix.'graph.list.sort', 'name'));
$sort_order = $this->getInput('sortorder', CProfile::get($prefix.'graph.list.sortorder', ZBX_SORT_UP));
CProfile::update($prefix.'graph.list.sort', $sort_field, PROFILE_TYPE_STR);
CProfile::update($prefix.'graph.list.sortorder', $sort_order, PROFILE_TYPE_STR);
if ($this->hasInput('filter_set')) {
CProfile::updateArray($prefix.'graph.list.filter_groupids', $this->getInput('filter_groupids', []),