'ipmi_sensor', 'authtype', 'username', 'password', 'publickey', 'privatekey', 'flags', 'interfaceid',
<?php declare(strict_types=0);
require 'include/forms.inc.php';
class CControllerItemEdit extends CControllerItem {
protected function init() {
$this->disableCsrfValidation();
protected function checkInput(): bool {
] + static::getValidationFields();
$ret = $this->validateInput($fields) && $this->validateReferredObjects();
if ($this->hasInput('clone') && !$this->hasInput('itemid')) {
error(_s('Incorrect value for "%1$s" field.', 'itemid'));
elseif (!$this->hasInput('itemid') && !$this->hasInput('hostid')) {
error(_s('Incorrect value for "%1$s" field.', 'hostid'));
(new CControllerResponseData(['main_block' => json_encode([
'messages' => array_column(get_and_clear_messages(), 'message')
public function doAction() {
$host = $this->getInput('context') === 'host' ? $this->getHost() : $this->getTemplate();
$item = $this->hasInput('clone') ? $this->getClone($host) : $this->getItem($host);
$item['context'] = $this->getInput('context');
$inherited_timeouts = getInheritedTimeouts($host['proxyid'])['timeouts'];
$item['inherited_timeout'] = array_key_exists($item['type'], $inherited_timeouts)
? $inherited_timeouts[$item['type']] : '';
if ($item['timeout'] === DB::getDefault('items', 'timeout')) {
$item['timeout'] = $item['inherited_timeout'];
if (!$item['discovered']) {
$set_inventory = array_column(API::Item()->get([
'output' => ['inventory_link'],
'hostids' => [$item['hostid']],
]), 'inventory_link', 'inventory_link');
foreach (getHostInventories() as $inventory_field) {
$inventory_fields[$inventory_field['nr']] = [
'label' => $inventory_field['title'],
'disabled' => array_key_exists($inventory_field['nr'], $set_inventory)
$key_value_type = CItemData::getValueTypeByKey();
foreach (CItemData::getKeysByItemType() as $type => $keys) {
foreach ($keys as $key) {
$value_type = $key_value_type[$key];
$value_type_keys += [$type => []];