Source
730
730
$search = (array_key_exists('search', $data) && $data['search'] !== '') ? $data['search'] : null;
731
731
$wildcard_enabled = array_key_exists('wildcard_allowed', $data) && strpos($search, '*') !== false;
732
732
733
733
switch ($data['object_name']) {
734
734
case 'hosts':
735
735
$options = [
736
736
'output' => ['name'],
737
737
'search' => ['name' => $search.($wildcard_enabled ? '*' : '')],
738
738
'searchWildcardsEnabled' => $wildcard_enabled,
739
739
'preservekeys' => true,
740
+
'sortfield' => 'name',
740
741
'limit' => $limit
741
742
];
742
743
743
744
$db_result = API::Host()->get($options);
744
745
break;
745
746
746
747
case 'items':
747
748
$hostids = null;
748
749
749
750
if (array_key_exists('host_pattern', $data)) {
771
772
}
772
773
773
774
$options = [
774
775
'output' => ['name'],
775
776
'search' => ['name' => $search.($wildcard_enabled ? '*' : '')],
776
777
'searchWildcardsEnabled' => $wildcard_enabled,
777
778
'filter' => array_key_exists('filter', $data) ? $data['filter'] : null,
778
779
'templated' => array_key_exists('real_hosts', $data) ? false : null,
779
780
'hostids' => $hostids,
780
781
'webitems' => true,
782
+
'sortfield' => 'name',
781
783
'limit' => $limit
782
784
];
783
785
784
786
$db_result = API::Item()->get($options);
785
787
break;
786
788
787
789
case 'graphs':
788
790
$options = [
789
791
'output' => ['name'],
790
792
'search' => ['name' => $search.($wildcard_enabled ? '*' : '')],
791
793
'hostids' => array_key_exists('hostid', $data) ? $data['hostid'] : null,
792
794
'templated' => array_key_exists('real_hosts', $data) ? false : null,
793
795
'searchWildcardsEnabled' => $wildcard_enabled,
796
+
'sortfield' => 'name',
794
797
'limit' => $limit
795
798
];
796
799
797
800
$db_result = API::Graph()->get($options);
798
801
break;
799
802
}
800
803
801
804
$result[] = [
802
805
'name' => $search,
803
806
'id' => $search