Source
xxxxxxxxxx
'output' => ['actionid', 'userid', 'clock', 'mediatypeid', 'sendto', 'subject', 'message', 'status',
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
namespace Widgets\ActionLog\Actions;
use API,
CControllerDashboardWidgetView,
CControllerResponseData,
CArrayHelper,
CSettingsHelper;
class WidgetView extends CControllerDashboardWidgetView {
protected function init(): void {
parent::init();
$this->addValidationRules([
'has_custom_time_period' => 'in 1'
]);
}
protected function doAction(): void {
[$sortfield, $sortorder] = self::getSorting($this->fields_values['sort_triggers']);
$data = [
'name' => $this->getInput('name', $this->widget->getDefaultName()),
'userids' => $this->fields_values['userids'],
'users' => [],
'actionids' => $this->fields_values['actionids'],
'actions' => [],
'mediatypeids' => $this->fields_values['mediatypeids'],
'media_types' => [],
'statuses' => $this->fields_values['statuses'],
'message' => $this->fields_values['message'],
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'info' => $this->makeWidgetInfo(),
'user' => [
'debug_mode' => $this->getDebugMode()
]
];
$userids = [];
if ($data['userids']) {
$data['users'] = API::User()->get([
'output' => ['userid', 'username', 'name', 'surname'],
'userids' => $data['userids'],
'preservekeys' => true
]);
$userids = array_keys($data['users']);
$data['userids'] = $this->prepareDataForMultiselect($data['users'], 'users');
}
$actionids = [];
if ($data['actionids']) {
$data['actions'] = API::Action()->get([
'output' => ['actionid', 'name'],
'actionids' => $data['actionids'],
'preservekeys' => true
]);
$actionids = array_keys($data['actions']);
$data['actionids'] = $this->prepareDataForMultiselect($data['actions'], 'actions');
}
$mediatypeids = [];
if ($data['mediatypeids']) {
$data['media_types'] = API::MediaType()->get([
'output' => ['mediatypeid', 'name', 'maxattempts'],
'mediatypeids' => $data['mediatypeids'],
'preservekeys' => true
]);
$mediatypeids = array_keys($data['media_types']);