Source
33
33
'groupids' => [T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, DB_ID, null],
34
34
'hostids' => [T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, DB_ID, null],
35
35
'severities' => [T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, null, null],
36
36
'filter_rst' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
37
37
'filter_set' => [T_ZBX_STR, O_OPT, P_SYS, null, null],
38
38
'from' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null],
39
39
'to' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null]
40
40
];
41
41
check_fields($fields);
42
42
43
-
$timeselector_from = hasRequest('from') ? getRequest('from') : CProfile::get('web.toptriggers.filter.from');
44
-
$timeselector_to = hasRequest('to') ? getRequest('to') : CProfile::get('web.toptriggers.filter.to');
43
+
if (hasRequest('from') || hasRequest('to')) {
44
+
validateTimeSelectorPeriod(
45
+
hasRequest('from') ? getRequest('from') : null,
46
+
hasRequest('to') ? getRequest('to') : null
47
+
);
48
+
}
45
49
46
-
validateTimeSelectorPeriod($timeselector_from, $timeselector_to);
50
+
$timeselector_from = getRequest('from', CProfile::get('web.toptriggers.filter.from',
51
+
'now-'.CSettingsHelper::get(CSettingsHelper::PERIOD_DEFAULT)));
52
+
$timeselector_to = getRequest('to', CProfile::get('web.toptriggers.filter.to', 'now'));
47
53
48
54
/*
49
55
* Filter
50
56
*/
51
57
if (hasRequest('filter_set')) {
52
58
CProfile::updateArray('web.toptriggers.filter.severities', getRequest('severities', []), PROFILE_TYPE_STR);
53
59
CProfile::updateArray('web.toptriggers.filter.groupids', getRequest('groupids', []), PROFILE_TYPE_STR);
54
60
CProfile::updateArray('web.toptriggers.filter.hostids', getRequest('hostids', []), PROFILE_TYPE_STR);
55
61
CProfile::update('web.toptriggers.filter.from', $timeselector_from, PROFILE_TYPE_STR);
56
62
CProfile::update('web.toptriggers.filter.to', $timeselector_to, PROFILE_TYPE_STR);
57
63
}
58
64
elseif (hasRequest('filter_rst')) {
59
65
DBstart();
60
66
CProfile::deleteIdx('web.toptriggers.filter.severities');
61
67
CProfile::deleteIdx('web.toptriggers.filter.groupids');
62
68
CProfile::deleteIdx('web.toptriggers.filter.hostids');
63
69
DBend();
64
70
}
65
71
66
-
$timeselector_options = [
67
-
'profileIdx' => 'web.toptriggers.filter',
68
-
'profileIdx2' => 0,
69
-
'from' => $timeselector_from,
70
-
'to' => $timeselector_to
71
-
];
72
-
73
72
$data['filter'] = [
74
73
'severities' => CProfile::getArray('web.toptriggers.filter.severities', []),
75
-
'timeline' => getTimeSelectorPeriod($timeselector_options),
74
+
'timeline' => getTimeSelectorPeriod([
75
+
'profileIdx' => 'web.toptriggers.filter',
76
+
'profileIdx2' => 0,
77
+
'from' => $timeselector_from,
78
+
'to' => $timeselector_to
79
+
]),
76
80
'active_tab' => CProfile::get('web.toptriggers.filter.active', 1)
77
81
];
78
82
79
83
// multiselect host groups
80
84
$data['multiSelectHostGroupData'] = [];
81
85
$groupids = CProfile::getArray('web.toptriggers.filter.groupids', []);
82
86
83
87
if ($groupids) {
84
88
$groupids = getSubGroups($groupids, $data['multiSelectHostGroupData']);
85
89
}