Source
xxxxxxxxxx
if (in_array($filter['tag_source'], [ZBX_SERVICE_FILTER_TAGS_ANY, ZBX_SERVICE_FILTER_TAGS_SERVICE])) {
<?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/>.
**/
abstract class CControllerServiceListGeneral extends CController {
protected const WITHOUT_PARENTS_SERVICEID = 0;
protected const FILTER_DEFAULT_NAME = '';
protected const FILTER_DEFAULT_STATUS = SERVICE_STATUS_ANY;
protected const FILTER_DEFAULT_WITHOUT_CHILDREN = false;
protected const FILTER_DEFAULT_WITHOUT_PROBLEM_TAGS = false;
protected const FILTER_DEFAULT_TAG_SOURCE = ZBX_SERVICE_FILTER_TAGS_SERVICE;
protected const FILTER_DEFAULT_EVALTYPE = TAG_EVAL_TYPE_AND_OR;
/**
* @var array
*/
protected $service;
/**
* @throws APIException
*
* @return bool
*/
protected function checkPermissions(): bool {
if ($this->hasInput('serviceid')) {
$db_service = API::Service()->get([
'output' => ['serviceid', 'name', 'status', 'readonly'],
'serviceids' => $this->getInput('serviceid'),
'selectParents' => ['serviceid'],
'selectTags' => ['tag', 'value']
]);
if (!$db_service) {
return false;
}
$this->service = $db_service[0];
}
return true;
}
/**
* @throws APIException
*
* @return bool
*/
protected function canEdit(): bool {
$db_roles = API::Role()->get([
'output' => [],
'selectRules' => ['services.write.mode', 'services.write.list', 'services.write.tag'],
'roleids' => CWebUser::$data['roleid']
]);
if ($db_roles) {
return ($db_roles[0]['rules']['services.write.mode'] == ZBX_ROLE_RULE_SERVICES_ACCESS_ALL
|| $db_roles[0]['rules']['services.write.list']
|| $db_roles[0]['rules']['services.write.tag']['tag'] !== '');
}
return false;
}
/**
* @throws APIException
*/
protected function doAction(): void {
if ($this->service !== null) {
$this->service['tags'] = makeTags([$this->service], true, 'serviceid');
$this->service['parents'] = API::Service()->get([
'output' => ['serviceid', 'name'],
'serviceids' => array_column($this->service['parents'], 'serviceid'),
'selectChildren' => API_OUTPUT_COUNT
]);
}
}