diff options
author | Miks Kronkalns <miks.kronkalns@zabbix.com> | 2020-10-07 10:25:26 +0300 |
---|---|---|
committer | Miks Kronkalns <miks.kronkalns@zabbix.com> | 2020-10-07 10:25:26 +0300 |
commit | 58d0a2b0f2775fd4bb6a04fd5513049dcebe9f28 (patch) | |
tree | e68280b86e06a3bfa5efe2e4a212e3c945eee8a2 | |
parent | 52150d95f4bc20b6698b5b52d91337760df0b7b1 (diff) |
..F....... [ZBXNEXT-5928] replaced code with equivalen equivalent function call
-rw-r--r-- | ui/app/controllers/CControllerHost.php | 69 |
1 files changed, 4 insertions, 65 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php index 2da74a44964..2a72c52ecea 100644 --- a/ui/app/controllers/CControllerHost.php +++ b/ui/app/controllers/CControllerHost.php @@ -65,45 +65,14 @@ abstract class CControllerHost extends CController { * @return int */ protected function getCount(array $filter): int { - $child_groups = []; - - if ($filter['groupids']) { - $filter_groups = API::HostGroup()->get([ - 'output' => ['groupid', 'name'], - 'groupids' => $filter['groupids'], - 'preservekeys' => true - ]); - - if ($filter_groups) { - foreach ($filter_groups as $group) { - $child_groups[] = $group['name'].'/'; - } - } - else { - $filter['groupids'] = []; - } - } - - $groupids = null; - - if ($child_groups) { - $filter_groups += API::HostGroup()->get([ - 'output' => ['groupid'], - 'search' => ['name' => $child_groups], - 'startSearch' => true, - 'searchByAny' => true, - 'preservekeys' => true - ]); - - $groupids = array_keys($filter_groups); - } + $groupids = $filter['groupids'] ? getSubGroups($filter['groupids']) : null; return (int) API::Host()->get([ 'countOutput' => true, 'evaltype' => $filter['evaltype'], 'tags' => $filter['tags'], 'inheritedTags' => true, - 'groupids' => $groupids, + 'groupids' => $groupids ? $groupids : null, 'severities' => $filter['severities'] ? $filter['severities'] : null, 'withProblemsSuppressed' => $filter['severities'] ? (($filter['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE) ? null : false) @@ -146,45 +115,15 @@ abstract class CControllerHost extends CController { * @return array */ protected function getData(array $filter): array { - $child_groups = []; + $groupids = $filter['groupids'] ? getSubGroups($filter['groupids'], $filter_groups) : null; - if ($filter['groupids']) { - $filter_groups = API::HostGroup()->get([ - 'output' => ['groupid', 'name'], - 'groupids' => $filter['groupids'], - 'preservekeys' => true - ]); - - if ($filter_groups) { - foreach ($filter_groups as $group) { - $child_groups[] = $group['name'].'/'; - } - } - else { - $filter['groupids'] = []; - } - } - - $groupids = null; - - if ($child_groups) { - $filter_groups += API::HostGroup()->get([ - 'output' => ['groupid'], - 'search' => ['name' => $child_groups], - 'startSearch' => true, - 'searchByAny' => true, - 'preservekeys' => true - ]); - - $groupids = array_keys($filter_groups); - } $limit = CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT) + 1; $hosts = API::Host()->get([ 'output' => ['hostid', 'name', 'status'], 'evaltype' => $filter['evaltype'], 'tags' => $filter['tags'], 'inheritedTags' => true, - 'groupids' => $groupids, + 'groupids' => $groupids ? $groupids : null, 'severities' => $filter['severities'] ? $filter['severities'] : null, 'withProblemsSuppressed' => $filter['severities'] ? (($filter['show_suppressed'] == ZBX_PROBLEM_SUPPRESSED_TRUE) ? null : false) |