<?php declare(strict_types = 0);
abstract class CControllerUserroleEditGeneral extends CController {
protected function getRulesInput(int $user_type): array {
$this->getUiSectionRules($user_type),
$this->getServiceSectionRules(),
$this->getModuleSectionRules(),
$this->getApiSectionRules(),
$this->getActionSectionRules($user_type)
private function getUiSectionRules(int $user_type): array {
function (string $rule): array {
'name' => str_replace('ui.', '', $rule),
'status' => $this->getInput(str_replace('.', '_', $rule))
CRoleHelper::getUiElementsByUserType($user_type)
'ui.default_access' => $this->getInput('ui_default_access')
private function getServiceSectionRules(): array {
$read_access = $this->getInput('service_read_access', CRoleHelper::SERVICES_ACCESS_NONE);
$write_access = $this->getInput('service_write_access', CRoleHelper::SERVICES_ACCESS_NONE);
'services.read.mode' => $read_access == CRoleHelper::SERVICES_ACCESS_ALL
? ZBX_ROLE_RULE_SERVICES_ACCESS_ALL
: ZBX_ROLE_RULE_SERVICES_ACCESS_CUSTOM,
'services.read.list' => $read_access == CRoleHelper::SERVICES_ACCESS_LIST
static function (string $serviceid): array {
return ['serviceid' => $serviceid];
$this->getInput('service_read_list', []))
'services.read.tag' => $read_access == CRoleHelper::SERVICES_ACCESS_LIST
'tag' => trim($this->getInput('service_read_tag_tag', '')),
'value' => trim($this->getInput('service_read_tag_value', ''))
: ['tag' => '', 'value' => ''],
'services.write.mode' => $write_access == CRoleHelper::SERVICES_ACCESS_ALL
? ZBX_ROLE_RULE_SERVICES_ACCESS_ALL
: ZBX_ROLE_RULE_SERVICES_ACCESS_CUSTOM,
'services.write.list' => $write_access == CRoleHelper::SERVICES_ACCESS_LIST
static function (string $serviceid): array {
return ['serviceid' => $serviceid];
$this->getInput('service_write_list', []))
'services.write.tag' => $write_access == CRoleHelper::SERVICES_ACCESS_LIST
'tag' => trim($this->getInput('service_write_tag_tag', '')),
'value' => trim($this->getInput('service_write_tag_value', ''))
: ['tag' => '', 'value' => '']