<?php declare(strict_types = 0);
class CControllerTemplateDashboardList extends CController {
protected function init() {
$this->disableCsrfValidation();
protected function checkInput() {
'templateid' => 'required|db dashboard.templateid',
'sortorder' => 'in '.ZBX_SORT_DOWN.','.ZBX_SORT_UP,
$ret = $this->validateInput($fields);
$this->setResponse(new CControllerResponseFatal());
protected function checkPermissions() {
if ($this->getUserType() < USER_TYPE_ZABBIX_ADMIN) {
return isWritableHostTemplates((array) $this->getInput('templateid'));
protected function doAction() {
$sort_field = $this->getInput('sort', CProfile::get('web.templates.dashboard.list.sort', 'name'));
$sort_order = $this->getInput('sortorder', CProfile::get('web.templates.dashboard.list.sortorder', ZBX_SORT_UP));
CProfile::update('web.templates.dashboard.list.sort', $sort_field, PROFILE_TYPE_STR);
CProfile::update('web.templates.dashboard.list.sortorder', $sort_order, PROFILE_TYPE_STR);
$limit = CSettingsHelper::get(CSettingsHelper::SEARCH_LIMIT) + 1;
$dashboards = API::TemplateDashboard()->get([
'output' => ['name', 'templateid'],
'templateids' => [$this->getInput('templateid')],
'sortfield' => $sort_field,