$del_hosts[$db_host['hostid']] = $db_host['hostid']; /* add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST,'Host ['.$db_host['host'].']');*/ } $result = delete_host($del_hosts, $unlink_mode); $result = DBend($result); show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); } unset($_REQUEST['delete']); } else { if (($_REQUEST['config'] == 0 || $_REQUEST['config'] == 3) && inarr_isset(array('add_to_group', 'hostid'))) { // if(!uint_in_array($_REQUEST['add_to_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))){ if (!isset($available_groups[$_REQUEST['add_to_group']])) { access_deny(); } DBstart(); $result = add_host_to_group($_REQUEST['hostid'], $_REQUEST['add_to_group']); $result = DBend($result); show_messages($result, S_HOST_UPDATED, S_CANNOT_UPDATE_HOST); } else { if (($_REQUEST['config'] == 0 || $_REQUEST['config'] == 3) && inarr_isset(array('delete_from_group', 'hostid'))) { // if(!uint_in_array($_REQUEST['delete_from_group'], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY))){ if (!isset($available_groups[$_REQUEST['delete_from_group']])) { access_deny(); } DBstart(); $result = delete_host_from_group($_REQUEST['hostid'], $_REQUEST['delete_from_group']); $result = DBend($result); show_messages($result, S_HOST_UPDATED, S_CANNOT_UPDATE_HOST); } else { if (($_REQUEST['config'] == 0 || $_REQUEST['config'] == 3) && (isset($_REQUEST['activate']) || isset($_REQUEST['disable']))) { $result = true;
/** * Add Hosts to HostGroup * * {@source} * @access public * @static * @since 1.8 * @version 1 * * @static * @param array $data * @return boolean */ public static function addHosts($data) { $result = add_host_to_group($data['hostids'], $data['groupid']); if ($result) { return true; } else { self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error'); return false; } }
function update_host_groups($hostid, $groups = array()) { DBexecute("delete from hosts_groups where hostid={$hostid}"); foreach ($groups as $groupid) { add_host_to_group($hostid, $groupid); } }
function update_host_groups($hostid, $groups = array()) { if (empty($groups)) { $host = get_host_by_hostid($hostid); error('Host "' . $host['host'] . '" can not exist without group'); return false; } DBexecute('DELETE FROM hosts_groups WHERE hostid=' . $hostid); foreach ($groups as $num => $groupid) { $result = add_host_to_group($hostid, $groupid); } return $result; }