Source
'value' => ['type' => API_STRING_UTF8, 'length' => DB::getFieldLength('host_tag', 'value'), 'default' => DB::getDefault('host_tag', 'value')]
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* Class containing methods for operations with hosts.
*/
abstract class CHostGeneral extends CHostBase {
public const ACCESS_RULES = [
'get' => ['min_user_type' => USER_TYPE_ZABBIX_USER],
'create' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'update' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'delete' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'massadd' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'massupdate' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN],
'massremove' => ['min_user_type' => USER_TYPE_ZABBIX_ADMIN]
];
/**
* Check for valid host groups.
*
* @param array $hosts
* @param array|null $db_hosts
*
* @throws APIException if groups are not valid.
*/
protected function checkGroups(array $hosts, array $db_hosts = null): void {
$id_field_name = $this instanceof CTemplate ? 'templateid' : 'hostid';
$edit_groupids = [];
foreach ($hosts as $host) {
if (!array_key_exists('groups', $host)) {
continue;
}
$groupids = array_column($host['groups'], 'groupid');
if ($db_hosts === null) {
$edit_groupids += array_flip($groupids);
}
else {
$db_groupids = array_column($db_hosts[$host[$id_field_name]]['groups'], 'groupid');
$ins_groupids = array_flip(array_diff($groupids, $db_groupids));