<?php declare(strict_types = 0);
class CControllerDiscoveryList extends CController {
protected function init() {
$this->disableCsrfValidation();
protected function checkInput() {
'sortorder' => 'in '.ZBX_SORT_DOWN.','.ZBX_SORT_UP,
'filter_name' => 'string',
'filter_status' => 'in -1,'.DRULE_STATUS_ACTIVE.','.DRULE_STATUS_DISABLED,
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions() {
return $this->checkAccess(CRoleHelper::UI_CONFIGURATION_DISCOVERY);
protected function doAction() {
$sort_field = $this->getInput('sort', CProfile::get('web.discoveryconf.php.sort', 'name'));
$sort_order = $this->getInput('sortorder', CProfile::get('web.discoveryconf.php.sortorder', ZBX_SORT_UP));
CProfile::update('web.discoveryconf.php.sort', $sort_field, PROFILE_TYPE_STR);
CProfile::update('web.discoveryconf.php.sortorder', $sort_order, PROFILE_TYPE_STR);
if ($this->hasInput('filter_set')) {
CProfile::update('web.discoveryconf.filter_name', $this->getInput('filter_name', ''), PROFILE_TYPE_STR);
CProfile::update('web.discoveryconf.filter_status', $this->getInput('filter_status', -1), PROFILE_TYPE_INT);
elseif ($this->hasInput('filter_rst')) {
CProfile::delete('web.discoveryconf.filter_name');
CProfile::delete('web.discoveryconf.filter_status');
'name' => CProfile::get('web.discoveryconf.filter_name', ''),
'status' => CProfile::get('web.discoveryconf.filter_status', -1)
'uncheck' => $this->hasInput('uncheck'),
'sortorder' => $sort_order,
'profileIdx' => 'web.discoveryconf.filter',
'active_tab' => CProfile::get('web.discoveryconf.filter.active', 1)
$limit = CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT) + 1;
$data['drules'] = API::DRule()->get([
'output' => ['proxy_hostid', 'name', 'status', 'iprange', 'delay'],
'selectDChecks' => ['type'],
'name' => ($filter['name'] === '') ? null : $filter['name']