. **/ class CControllerGraphDelete extends CController { protected function init(): void { $this->setPostContentType(self::POST_CONTENT_TYPE_JSON); } protected function checkInput(): bool { $fields = [ 'graphids' => 'required|array_db graphs.graphid' ]; $ret = $this->validateInput($fields); if (!$ret) { $this->setResponse( (new CControllerResponseData(['main_block' => json_encode([ 'error' => [ 'messages' => array_column(get_and_clear_messages(), 'message') ] ])]))->disableView() ); } return $ret; } protected function checkPermissions(): bool { return $this->getUserType() == USER_TYPE_ZABBIX_ADMIN || $this->getUserType() == USER_TYPE_SUPER_ADMIN; } protected function doAction(): void { $graphids = $this->getInput('graphids'); $graphs_count = count($graphids); $result = API::Graph()->delete($graphids); $output = []; if ($result) { $output['success']['title'] = _n('Graph deleted', 'Graphs deleted', $graphs_count); $output['success']['action'] = 'delete'; if ($messages = get_and_clear_messages()) { $output['success']['messages'] = array_column($messages, 'message'); } } else { $output['error'] = [ 'title' => _n('Cannot delete graph', 'Cannot delete graphs', $graphs_count), 'messages' => array_column(get_and_clear_messages(), 'message') ]; $graphs = API::Graph()->get([ 'output' => [], 'graphids' => $graphids, 'preservekeys' => true ]); $output['keepids'] = array_keys($graphs); } $this->setResponse(new CControllerResponseData(['main_block' => json_encode($output)])); } }