Source
$master_items = self::getItems($master_column['item'], $master_items_only_numeric_allowed, $groupids, $hostids);
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2021 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 CControllerWidgetTopHostsView extends CControllerWidget {
public function __construct() {
parent::__construct();
$this->setType(WIDGET_TOP_HOSTS);
$this->setValidationRules([
'name' => 'string',
'fields' => 'json'
]);
}
protected function doAction() {
$data = [
'name' => $this->getInput('name', $this->getDefaultName()),
'user' => [
'debug_mode' => $this->getDebugMode()
]
];
$data += self::getData($this->getForm()->getFieldsData());
$this->setResponse(new CControllerResponseData($data));
}
/**
* @param array $fields
*
* @throws Exception
*
* @return array
*/
private static function getData(array $fields): array {
$configuration = $fields['columns'];
$groupids = $fields['groupids'] ? getSubGroups($fields['groupids']) : null;
$hostids = $fields['hostids'] ?: null;
if (array_key_exists('tags', $fields)) {
$hosts = API::Host()->get([
'output' => ['name'],
'groupids' => $groupids,