<?php declare(strict_types = 0);
require_once dirname(__FILE__).'/../../include/forms.inc.php';
class CControllerPopupMassupdateItem extends CController {
private $opt_interfaceid_expected = false;
protected function checkInput() {
$fields = [
'allow_traps' => 'in '.implode(',', [HTTPCHECK_ALLOW_TRAPS_ON, HTTPCHECK_ALLOW_TRAPS_OFF]),
'authtype' => 'string',
'context' => 'required|string|in host,template',
'delay' => 'string',
'delay_flex' => 'array',
'description' => 'string',
'discover' => 'in '.ZBX_PROTOTYPE_DISCOVER.','.ZBX_PROTOTYPE_NO_DISCOVER,
'headers' => 'array',
'history' => 'string',
'history_mode' => 'in '.implode(',', [ITEM_STORAGE_OFF, ITEM_STORAGE_CUSTOM]),
'ids' => 'required|array_id',
'interfaceid' => 'id',
'jmx_endpoint' => 'string',
'logtimefmt' => 'string',
'mass_update_tags' => 'in '.implode(',', [ZBX_ACTION_ADD, ZBX_ACTION_REPLACE, ZBX_ACTION_REMOVE]),
'master_itemid' => 'id',
'parent_discoveryid' => 'id',
'password' => 'string',
'post_type' => 'in '.implode(',', [ZBX_POSTTYPE_RAW, ZBX_POSTTYPE_JSON, ZBX_POSTTYPE_XML]),
'posts' => 'string',
'preprocessing' => 'array',
'privatekey' => 'string',
'prototype' => 'required|in 0,1',
'publickey' => 'string',
'status' => 'in '.implode(',', [ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED]),
'tags' => 'array',
'trapper_hosts' => 'string',
'trends' => 'string',
'trends_mode' => 'in '.implode(',', [ITEM_STORAGE_OFF, ITEM_STORAGE_CUSTOM]),
'timeout' => 'string',
'type' => 'int32',
'units' => 'string',
'update' => 'in 1',
'url' => 'string',
'username' => 'string',
'value_type' => 'in '.implode(',', [ITEM_VALUE_TYPE_UINT64, ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT]),
'valuemapid' => 'id',
'visible' => 'array'
];
$this->opt_interfaceid_expected = (getRequest('interfaceid') == INTERFACE_TYPE_OPT);
if ($this->opt_interfaceid_expected) {
unset($fields['interfaceid']);
unset($_REQUEST['interfaceid']);
}
$ret = $this->validateInput($fields);
if ($ret && $this->opt_interfaceid_expected) {
if ($this->hasInput('type')) {
$item_types = [$this->getInput('type')];
}
else {
$options = [
'output' => ['type'],
'itemids' => $this->getInput('ids')
];
$item_types = (bool) $this->getInput('prototype')
? API::ItemPrototype()->get($options)
: API::Item()->get($options);