<?php declare(strict_types = 0);
class CControllerScheduledReportEdit extends CController {
protected function init() {
$this->disableCsrfValidation();
protected function checkInput() {
'reportid' => 'db report.reportid',
'userid' => 'db report.userid',
'name' => 'db report.name',
'dashboardid' => 'db report.dashboardid',
'old_dashboardid' => 'db report.dashboardid',
'period' => 'db report.period|in '.implode(',', [ZBX_REPORT_PERIOD_DAY, ZBX_REPORT_PERIOD_WEEK, ZBX_REPORT_PERIOD_MONTH, ZBX_REPORT_PERIOD_YEAR]),
'cycle' => 'db report.cycle|in '.implode(',', [ZBX_REPORT_CYCLE_DAILY, ZBX_REPORT_CYCLE_WEEKLY, ZBX_REPORT_CYCLE_MONTHLY, ZBX_REPORT_CYCLE_YEARLY]),
'active_since' => 'string',
'active_till' => 'string',
'subscriptions' => 'array',
'description' => 'db report.description',
'status' => 'db report.status|in '.ZBX_REPORT_STATUS_DISABLED.','.ZBX_REPORT_STATUS_ENABLED,
'form_refresh' => 'int32'
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions() {
if (!$this->checkAccess(CRoleHelper::UI_REPORTS_SCHEDULED_REPORTS)
|| (!$this->hasInput('reportid')
&& !$this->checkAccess(CRoleHelper::ACTIONS_MANAGE_SCHEDULED_REPORTS))) {
if ($this->hasInput('reportid') && !$this->hasInput('form_refresh')) {
if (!$this->getInput('reportid', 0)) {
$reports = API::Report()->get([
'output' => ['reportid', 'userid', 'name', 'description', 'status', 'dashboardid', 'period', 'cycle',
'weekdays', 'start_time', 'active_since', 'active_till', 'subject', 'message'
'selectUsers' => ['userid', 'access_userid', 'exclude'],
'selectUserGroups' => ['usrgrpid', 'access_userid'],
'reportids' => $this->getInput('reportid')
$this->report = $reports[0];
protected function doAction() {
$db_defaults = DB::getDefaults('report');
$current_user_name = getUserFullname(CWebUser::$data);