<?php declare(strict_types = 0);
require_once dirname(__FILE__).'/../../include/forms.inc.php';
class CControllerPopupMassupdateHost extends CControllerPopupMassupdateAbstract {
protected function checkInput(): bool {
'hostids' => 'required|array',
'host_inventory' => 'array',
'inventories' => 'array',
'description' => 'string',
'monitored_by' => 'in '.implode(',', [ZBX_MONITORED_BY_SERVER, ZBX_MONITORED_BY_PROXY, ZBX_MONITORED_BY_PROXY_GROUP]),
'proxy_groupid' => 'string',
'ipmi_username' => 'string',
'ipmi_password' => 'string',
'tls_issuer' => 'string',
'tls_subject' => 'string',
'tls_psk_identity' => 'string',
'valuemap_remove' => 'array',
'valuemap_remove_except' => 'in 1',
'valuemap_remove_all' => 'in 1',
'valuemap_rename' => 'array',
'valuemap_update_existing' => 'in 1',
'valuemap_add_missing' => 'in 1',
'macros_add' => 'in 0,1',
'macros_update' => 'in 0,1',
'macros_remove' => 'in 0,1',
'macros_remove_all' => 'in 0,1',
'mass_clear_tpls' => 'in 0,1',
'mass_action_tpls' => 'in '.implode(',', [ZBX_ACTION_ADD, ZBX_ACTION_REPLACE, ZBX_ACTION_REMOVE]),
'mass_update_groups' => 'in '.implode(',', [ZBX_ACTION_ADD, ZBX_ACTION_REPLACE, ZBX_ACTION_REMOVE]),
'mass_update_tags' => 'in '.implode(',', [ZBX_ACTION_ADD, ZBX_ACTION_REPLACE, ZBX_ACTION_REMOVE]),
'mass_update_macros' => 'in '.implode(',', [ZBX_ACTION_ADD, ZBX_ACTION_REPLACE, ZBX_ACTION_REMOVE, ZBX_ACTION_REMOVE_ALL]),
'valuemap_massupdate' => 'in '.implode(',', [ZBX_ACTION_ADD, ZBX_ACTION_REPLACE, ZBX_ACTION_REMOVE, ZBX_ACTION_RENAME, ZBX_ACTION_REMOVE_ALL]),
'inventory_mode' => 'in '.implode(',', [HOST_INVENTORY_DISABLED, HOST_INVENTORY_MANUAL, HOST_INVENTORY_AUTOMATIC]),
'status' => 'in '.implode(',', [HOST_STATUS_MONITORED, HOST_STATUS_NOT_MONITORED]),
'tls_connect' => 'in '.implode(',', [HOST_ENCRYPTION_NONE, HOST_ENCRYPTION_PSK, HOST_ENCRYPTION_CERTIFICATE]),
'tls_accept' => 'ge 0|le '.(HOST_ENCRYPTION_NONE | HOST_ENCRYPTION_PSK | HOST_ENCRYPTION_CERTIFICATE),
'ipmi_authtype' => 'in '.implode(',', [IPMI_AUTHTYPE_DEFAULT, IPMI_AUTHTYPE_NONE, IPMI_AUTHTYPE_MD2, IPMI_AUTHTYPE_MD5, IPMI_AUTHTYPE_STRAIGHT, IPMI_AUTHTYPE_OEM, IPMI_AUTHTYPE_RMCP_PLUS]),
'ipmi_privilege' => 'in '.implode(',', [IPMI_PRIVILEGE_CALLBACK, IPMI_PRIVILEGE_USER, IPMI_PRIVILEGE_OPERATOR, IPMI_PRIVILEGE_ADMIN, IPMI_PRIVILEGE_OEM]),
$ret = $this->validateInput($fields);
if ($ret && $this->hasInput('tags')) {
foreach ($this->getInput('tags') as $tag) {
if (!is_array($tag) || count($tag) != 2
|| !array_key_exists('tag', $tag) || !is_string($tag['tag'])
|| !array_key_exists('value', $tag) || !is_string($tag['value'])) {
error(_s('Incorrect value for "%1$s" field.', 'tags'));
(new CControllerResponseData(['main_block' => json_encode([
'messages' => array_column(get_and_clear_messages(), 'message')