<?php declare(strict_types = 0);
class CControllerHostUpdate extends CControllerHostUpdateGeneral {
protected function checkInput(): bool {
$ret = $this->validateInput(['hostid' => 'required|db hosts.hostid'] + self::getValidationFields());
new CControllerResponseData(['main_block' => json_encode([
'title' => _('Cannot update host'),
'messages' => array_column(get_and_clear_messages(), 'message')
protected function checkPermissions(): bool {
if (!$this->checkAccess(CRoleHelper::UI_CONFIGURATION_HOSTS)) {
$this->host = API::Host()->get([
'output' => ['hostid', 'host', 'name', 'monitored_by', 'proxyid', 'proxy_groupid', 'assigned_proxyid',
'status', 'description', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password',
'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'flags', 'inventory_mode'
'selectMacros' => ['hostmacroid', 'macro', 'value', 'type', 'description', 'automatic'],
'hostids' => $this->getInput('hostid'),
$this->host = $this->host[0];
protected function doAction(): void {
$inventory_enabled = false;
if ($this->getInput('inventory_mode', $this->host['inventory_mode']) != HOST_INVENTORY_DISABLED) {
$inventory_enabled = true;
$clear_templates = array_diff(
$this->getInput('clear_templates', []),
$this->getInput('add_templates', [])
'hostid' => $this->host['hostid'],
'host' => $this->getInput('host', $this->host['host']),
'name' => $this->getInput('visiblename', $this->host['name']),
'monitored_by' => $this->getInput('monitored_by', $this->host['monitored_by']),
'status' => $this->getInput('status', $this->host['status']),
'groups' => $this->processHostGroups($this->getInput('groups', [])),
'interfaces' => $this->processHostInterfaces($this->getInput('interfaces', [])),
'tags' => $this->processTags($this->getInput('tags', [])),
'templates' => $this->processTemplates([
$this->getInput('add_templates', []), $this->getInput('templates', [])