// 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; $status = isset($_REQUEST['activate']) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $hosts = get_request('hosts', array()); $act_hosts = array(); $sql = 'SELECT host,hostid,status ' . ' FROM hosts ' . ' WHERE ' . DBin_node('hostid') . ' AND ' . DBcondition('hostid', $hosts) . ' AND ' . DBcondition('hostid', $available_hosts); $db_hosts = DBselect($sql); DBstart(); while ($db_host = DBfetch($db_hosts)) { $act_hosts[$db_host['hostid']] = $db_host['hostid']; /* add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,'Host ['.$db_host['host'].']. Old status ['.$db_host['status'].'] '.'New status ['.$status.']');*/ }
/** * Add Hosts to HostGroup * * {@source} * @access public * @static * @since 1.8 * @version 1 * * @static * @param array $data * @return boolean */ public static function removeHosts($data) { $groupid = $data['groupid']; $hostids = $data['hostids']; DBstart(false); foreach ($hostids as $key => $hostid) { $result = delete_host_from_group($hostid, $groupid); if (!$result) { break; } } $result = DBend($result); if ($result) { return true; } else { self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error'); return false; } }