Source
* @param array $prepared_data [IN/OUT] Result of items matching primary filter.
<?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/>.
**/
/**
* Base controller for the "Latest data" page and the "Latest data" asynchronous refresh page.
*/
abstract class CControllerLatest extends CController {
// Filter idx prefix.
public const FILTER_IDX = 'web.monitoring.latest';
// Number of tag value rows allowed to be included in subfilter.
public const SUBFILTERS_TAG_VALUE_ROWS = 10;
// Number of tag value rows when tag values subfilter is expanded.
private const SUBFILTERS_TAG_VALUE_ROWS_EXPANDED = 200;
// Filter fields default values.
public const FILTER_FIELDS_DEFAULT = [
'groupids' => [],
'hostids' => [],
'name' => '',
'evaltype' => TAG_EVAL_TYPE_AND_OR,
'tags' => [],
'state' => -1,
'show_tags' => SHOW_TAGS_3,
'tag_name_format' => TAG_NAME_FULL,
'tag_priority' => '',
'show_details' => 0,
'page' => null,
'sort' => 'name',
'sortorder' => ZBX_SORT_UP,
'subfilter_hostids' => [],
'subfilter_tagnames' => [],
'subfilter_tags' => [],
'subfilter_state' => [],
'subfilter_data' => []
];
// Mandatory filter fields.
public const MANDATORY_FILTER_FIELDS = ['groupids', 'hostids', 'name', 'tags', 'state'];
/**
* Prepare the latest data based on the given filter and sorting options.
*
* @param array $filter Item filter options.
* @param array $filter['groupids'] Filter items by host groups.
* @param array $filter['hostids'] Filter items by hosts.
* @param string $filter['name'] Filter items by name.
* @param int $filter['evaltype'] Filter evaltype.