<?php declare(strict_types = 0);
class CControllerActionOperationGet extends CController {
protected function checkInput(): bool {
'eventsource' => 'required|in '.implode(',', [EVENT_SOURCE_TRIGGERS, EVENT_SOURCE_DISCOVERY, EVENT_SOURCE_AUTOREGISTRATION, EVENT_SOURCE_INTERNAL, EVENT_SOURCE_SERVICE]),
'recovery' => 'required|in '.implode(',', [ACTION_OPERATION, ACTION_RECOVERY_OPERATION, ACTION_UPDATE_OPERATION]),
$ret = $this->validateInput($fields) && $this->validateInputConstraints();
if (($messages = getMessages()) !== null) {
$output['errors'] = $messages->toString();
$this->setResponse(new CControllerResponseData(['main_block' => json_encode($output)]));
protected function validateInputConstraints(): bool {
$eventsource = $this->getInput('eventsource');
$recovery = $this->getInput('recovery');
$allowed_operations = getAllowedOperations($eventsource);
if (!array_key_exists($recovery, $allowed_operations)) {
error(_('Unsupported operation.'));
protected function checkPermissions(): bool {
return $this->getUserType() >= USER_TYPE_ZABBIX_ADMIN;
protected function doAction(): void {
$operation = $this->getInput('operation', []) + $this->defaultOperationObject();
$eventsource = (int) $this->getInput('eventsource');
$recovery = (int) $this->getInput('recovery');
'popup_config' => $this->popupConfig($operation, $eventsource, $recovery),
if ($this->getDebugMode() == GROUP_DEBUG_MODE_ENABLED) {
CProfiler::getInstance()->stop();
$data['debug'] = CProfiler::getInstance()->make()->toString();
$this->setResponse(new CControllerResponseData(['main_block' => json_encode($data)]));
private function defaultOperationObject(): array {