<?php declare(strict_types = 0);
class CControllerPopupScheduledReportEdit extends CController {
protected function init() {
$this->disableCsrfValidation();
protected function checkInput() {
'dashboardid' => 'required|db report.dashboardid'
$ret = $this->validateInput($fields);
(new CControllerResponseData(['main_block' => json_encode([
'messages' => array_column(get_and_clear_messages(), 'message')
protected function checkPermissions() {
return $this->checkAccess(CRoleHelper::UI_REPORTS_SCHEDULED_REPORTS)
&& $this->checkAccess(CRoleHelper::ACTIONS_MANAGE_SCHEDULED_REPORTS);
protected function doAction() {
$db_defaults = DB::getDefaults('report');
$current_user_name = getUserFullname(CWebUser::$data);
'userid' => CWebUser::$data['userid'],
'name' => $db_defaults['name'],
'dashboardid' => $this->getInput('dashboardid', 0),
'period' => $db_defaults['period'],
'cycle' => $db_defaults['cycle'],
'recipientid' => CWebUser::$data['userid'],
'recipient_type' => ZBX_REPORT_RECIPIENT_TYPE_USER,
'recipient_name' => $current_user_name,
'recipient_inaccessible' => 0,
'creatorid' => CWebUser::$data['userid'],
'creator_type' => ZBX_REPORT_CREATOR_TYPE_USER,
'creator_name' => $current_user_name,
'creator_inaccessible' => 0,
'exclude' => ZBX_REPORT_EXCLUDE_USER_FALSE
'description' => $db_defaults['description'],
'status' => $db_defaults['status'],
'allowed_edit' => $this->checkAccess(CRoleHelper::ACTIONS_MANAGE_SCHEDULED_REPORTS)
$this->getInputs($data, ['name', 'period', 'cycle', 'hours', 'minutes', 'active_since', 'active_till',
'subject', 'message', 'description', 'status', 'form_refresh'
if ($data['form_refresh'] != 0) {
$data['userid'] = $this->getInput('userid', 0);
$data['dashboardid'] = $this->getInput('dashboardid', 0);
$data['weekdays'] = array_sum($this->getInput('weekdays', []));
$data['subscriptions'] = $this->getInput('subscriptions', []);