Source
($this->context === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD) ? $this->getInput('templateid') : null
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* Controller for sanitizing fields of widgets before pasting previously copied widget.
*/
class CControllerDashboardWidgetsSanitize extends CController {
private $context;
private $widgets = [];
protected function init() {
$this->setPostContentType(self::POST_CONTENT_TYPE_JSON);
}
protected function checkInput() {
$fields = [
'templateid' => 'db dashboard.templateid',
'widgets' => 'array'
];
$ret = $this->validateInput($fields);
if ($ret) {
$this->context = $this->hasInput('templateid')
? CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD
: CWidgetConfig::CONTEXT_DASHBOARD;
foreach ($this->getInput('widgets', []) as $widget) {
$validator = new CNewValidator($widget, [
'type' => 'required|string',
'fields' => 'required|json'
]);
foreach ($validator->getAllErrors() as $error) {
error($error);
}
if ($validator->isErrorFatal() || $validator->isError()) {
$ret = false;
break;
}
$widget = $validator->getValidInput();