Source
57
57
}
58
58
if (!empty($elements['hosts'])) {
59
59
$options['hostids'] = array_unique($elements['hosts']);
60
60
}
61
61
if (!empty($elements['triggers'])) {
62
62
$options['triggerids'] = array_unique($elements['triggers']);
63
63
}
64
64
$triggerids = API::Trigger()->get($options);
65
65
66
66
return API::Event()->get([
67
+
'source' => EVENT_SOURCE_TRIGGERS,
68
+
'object' => EVENT_OBJECT_TRIGGER,
67
69
'countOutput' => true,
68
70
'objectids' => zbx_objectValues($triggerids, 'triggerid'),
69
71
'filter' => [
70
72
'value' => $value_event,
71
73
'acknowledged' => $ack ? 1 : 0
72
74
]
73
75
]);
74
76
}
75
77
76
78
/**
340
342
_('Actions')
341
343
]);
342
344
343
345
$events = API::Event()->get([
344
346
'output' => ['eventid', 'source', 'object', 'objectid', 'acknowledged', 'clock', 'ns', 'severity', 'r_eventid',
345
347
'cause_eventid'
346
348
],
347
349
'selectAcknowledges' => ['userid', 'clock', 'message', 'action', 'old_severity', 'new_severity',
348
350
'suppress_until', 'taskid'
349
351
],
350
-
'objectids' => $startEvent['objectid'],
352
+
'source' => EVENT_SOURCE_TRIGGERS,
353
+
'object' => EVENT_OBJECT_TRIGGER,
351
354
'value' => TRIGGER_VALUE_TRUE,
355
+
'objectids' => $startEvent['objectid'],
352
356
'eventid_till' => $startEvent['eventid'],
353
357
'sortfield' => ['clock', 'eventid'],
354
358
'sortorder' => ZBX_SORT_DOWN,
355
359
'limit' => 20,
356
360
'preservekeys' => true
357
361
]);
358
362
359
363
$r_eventids = [];
360
364
361
365
foreach ($events as $event) {
362
366
$r_eventids[$event['r_eventid']] = true;
363
367
}
364
368
unset($r_eventids[0]);
365
369
366
370
$r_events = $r_eventids
367
371
? API::Event()->get([
368
372
'output' => ['clock'],
373
+
'source' => EVENT_SOURCE_TRIGGERS,
374
+
'object' => EVENT_OBJECT_TRIGGER,
369
375
'eventids' => array_keys($r_eventids),
370
376
'preservekeys' => true
371
377
])
372
378
: [];
373
379
374
380
$triggerids = [];
375
381
foreach ($events as &$event) {
376
382
$triggerids[] = $event['objectid'];
377
383
378
384
$event['r_clock'] = array_key_exists($event['r_eventid'], $r_events)
400
406
foreach ($events as $event) {
401
407
$duration = ($event['r_eventid'] != 0)
402
408
? zbx_date2age($event['clock'], $event['r_clock'])
403
409
: zbx_date2age($event['clock']);
404
410
405
411
$can_be_closed = $allowed['close'];
406
412
$in_closing = false;
407
413
408
414
if ($event['r_eventid'] != 0) {
409
415
$value = TRIGGER_VALUE_FALSE;
410
-
$value_str = _('RESOLVED');
411
416
$value_clock = $event['r_clock'];
412
417
$can_be_closed = false;
413
418
}
414
419
else {
415
420
if (hasEventCloseAction($event['acknowledges'])) {
416
421
$in_closing = true;
417
422
$can_be_closed = false;
418
423
}
419
424
420
425
$value = $in_closing ? TRIGGER_VALUE_FALSE : TRIGGER_VALUE_TRUE;