Index: include/forms.inc.php =================================================================== --- include/forms.inc.php (revision 32355) +++ include/forms.inc.php (working copy) @@ -1131,22 +1131,18 @@ if (empty($data['parent_discoveryid'])) { $data['possibleHostInventories'] = getHostInventories(); + $inv_fields = zbx_objectValues($data['possibleHostInventories'], 'nr'); + // get already populated fields by other items $data['alreadyPopulated'] = API::item()->get(array( 'output' => array('inventory_link'), - 'filter' => array('hostid' => $data['hostid']), + 'hostids' => array($data['hostid']), + 'filter' => array('inventory_link' => $inv_fields), 'nopermissions' => true )); $data['alreadyPopulated'] = zbx_toHash($data['alreadyPopulated'], 'inventory_link'); } - // host groups - $data['hostGroups'] = API::HostGroup()->get(array( - 'editable' => true, - 'output' => API_OUTPUT_EXTEND - )); - order_result($data['hostGroups'], 'name'); - // template $data['is_template'] = isTemplate($data['hostid']); Index: include/views/configuration.template.edit.php =================================================================== --- include/views/configuration.template.edit.php (revision 32355) +++ include/views/configuration.template.edit.php (working copy) @@ -41,9 +41,9 @@ $dbTemplates = API::Template()->get(array( 'templateids' => $templateid, 'selectGroups' => API_OUTPUT_EXTEND, - 'selectParentTemplates' => API_OUTPUT_EXTEND, + 'selectParentTemplates' => array('name'), 'selectMacros' => API_OUTPUT_EXTEND, - 'output' => API_OUTPUT_EXTEND + 'output' => array('templateid', 'host', 'name') )); $dbTemplate = reset($dbTemplates); @@ -86,8 +86,8 @@ // get template hosts from db $hosts_linked_to = API::Host()->get(array( 'templateids' => $templateid, - 'editable' => 1, - 'templated_hosts' => 1 + 'editable' => true, + 'templated_hosts' => true )); $hosts_linked_to = zbx_objectValues($hosts_linked_to, 'hostid'); @@ -123,8 +123,8 @@ // get all Groups $group_tb = new CTweenBox($frmHost, 'groups', $groups, 10); $options = array( - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND + 'editable' => true, + 'output' => array('name') ); $all_groups = API::HostGroup()->get($options); order_result($all_groups, 'name'); @@ -165,9 +165,9 @@ // get hosts from selected twb_groupid combo $params = array( 'groupids' => $twb_groupid, - 'templated_hosts' => 1, - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND + 'templated_hosts' => true, + 'editable' => true, + 'output' => array('name') ); $db_hosts = API::Host()->get($params); order_result($db_hosts, 'name'); @@ -182,9 +182,9 @@ // select selected hosts and add them $params = array( 'hostids' => $hosts_linked_to, - 'templated_hosts' => 1, - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND + 'templated_hosts' => true, + 'editable' => true, + 'output' => array('name') ); $db_hosts = API::Host()->get($params); order_result($db_hosts, 'name'); @@ -224,7 +224,7 @@ 'hostids' => $templateid, 'inherited' => false, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL), - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name', 'key_'), )); if (!empty($hostItems)) { $itemsList = array(); @@ -244,7 +244,7 @@ $hostTriggers = API::Trigger()->get(array( 'inherited' => false, 'hostids' => $templateid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('description'), 'filter' => array('flags' => array(ZBX_FLAG_DISCOVERY_NORMAL)) )); if (!empty($hostTriggers)) { @@ -266,7 +266,7 @@ 'inherited' => false, 'hostids' => $templateid, 'filter' => array('flags' => array(ZBX_FLAG_DISCOVERY_NORMAL)), - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name'), )); if (!empty($hostGraphs)) { $graphsList = array(); @@ -286,7 +286,7 @@ $hostDiscoveryRules = API::DiscoveryRule()->get(array( 'inherited' => false, 'hostids' => $templateid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name', 'key_') )); if (!empty($hostDiscoveryRules)) { $discoveryRuleList = array(); @@ -307,7 +307,7 @@ 'hostids' => $templateid, 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name', 'key_') )); if (!empty($hostItemPrototypes)) { $prototypeList = array(); @@ -328,7 +328,7 @@ 'hostids' => $templateid, 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, - 'output' => API_OUTPUT_EXTEND + 'output' => array('description') )); if (!empty($hostTriggerPrototypes)) { $prototypeList = array(); @@ -349,7 +349,7 @@ 'hostids' => $templateid, 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('graphid', 'name'), )); if (!empty($hostGraphPrototypes)) { $prototypeList = array(); Index: include/views/configuration.host.massupdate.php =================================================================== --- include/views/configuration.host.massupdate.php (revision 32355) +++ include/views/configuration.host.massupdate.php (working copy) @@ -59,7 +59,7 @@ $proxyComboBox = new CComboBox('proxy_hostid', $this->data['proxy_hostid']); $proxyComboBox->addItem(0, _('(no proxy)')); foreach ($this->data['proxies'] as $proxie) { - $proxyComboBox->addItem($proxie['hostid'], $proxie['host']); + $proxyComboBox->addItem($proxie['proxyid'], $proxie['host']); } $hostFormList->addRow( array( Index: include/views/configuration.host.edit.php =================================================================== --- include/views/configuration.host.edit.php (revision 32355) +++ include/views/configuration.host.edit.php (working copy) @@ -57,16 +57,17 @@ 'selectParentTemplates' => array('templateid', 'name'), 'selectMacros' => API_OUTPUT_EXTEND, 'selectInventory' => true, - 'output' => API_OUTPUT_EXTEND + 'output' => array('hostid', 'host', 'name', 'proxy_hostid', 'status', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password'), )); $dbHost = reset($dbHosts); $dbHost['interfaces'] = API::HostInterface()->get(array( 'hostids' => $dbHost['hostid'], 'output' => API_OUTPUT_EXTEND, - 'selectItems' => array('type'), + 'selectItems' => API_OUTPUT_COUNT, 'sortfield' => 'interfaceid', - 'preservekeys' => true + 'preservekeys' => true, + 'nopermissions' => true )); $frm_title .= SPACE.' ['.$dbHost['host'].']'; @@ -131,18 +132,12 @@ $interfaces = $dbHost['interfaces']; foreach ($interfaces as $hinum => $interface) { $interfaces[$hinum]['items'] = 0; - $interfaces[$hinum]['items'] = count($dbHost['interfaces'][$interface['interfaceid']]['items']); + $interfaces[$hinum]['items'] = $dbHost['interfaces'][$interface['interfaceid']]['items']; // check if interface has items that require specific interface type, if so type cannot be changed - $locked = 0; - foreach ($dbHost['interfaces'][$interface['interfaceid']]['items'] as $item) { - $itemInterfaceType = itemTypeInterface($item['type']); - if (!($itemInterfaceType === false || $itemInterfaceType === INTERFACE_TYPE_ANY)) { - $locked = 1; - break; - } + if ($interfaces[$hinum]['items']) { + $interfaces[$hinum]['locked'] = true; } - $interfaces[$hinum]['locked'] = $locked; } } @@ -176,7 +171,7 @@ $grp_tb = new CTweenBox($frmHost, 'groups', $host_groups, 10); $all_groups = API::HostGroup()->get(array( 'editable' => true, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') )); order_result($all_groups, 'name'); foreach ($all_groups as $group) { @@ -283,7 +278,7 @@ $cmbProxy = new CComboBox('proxy_hostid', $proxy_hostid); $cmbProxy->addItem(0, _('(no proxy)')); -$db_proxies = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND)); +$db_proxies = API::Proxy()->get(array('output' => array('host'))); order_result($db_proxies, 'host'); foreach ($db_proxies as $proxy) { @@ -323,7 +318,7 @@ 'hostids' => $_REQUEST['hostid'], 'inherited' => false, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL), - 'output' => API_OUTPUT_EXTEND + 'output' => array('name', 'key_') )); if (!empty($hostItems)) { $itemsList = array(); @@ -346,7 +341,7 @@ 'triggerid', 'description' ), - 'selectItems' => API_OUTPUT_EXTEND, + 'selectItems' => API_OUTPUT_SHORTEN, 'filter' => array('flags' => array(ZBX_FLAG_DISCOVERY_NORMAL)) )); @@ -376,8 +371,8 @@ 'hostids' => $_REQUEST['hostid'], 'filter' => array('flags' => array(ZBX_FLAG_DISCOVERY_NORMAL)), 'selectHosts' => API_OUTPUT_REFER, - 'selectItems' => API_OUTPUT_EXTEND, - 'output' => API_OUTPUT_EXTEND + 'selectItems' => API_OUTPUT_SHORTEN, + 'output' => array('name'), )); if (!empty($hostGraphs)) { $graphsList = array(); @@ -407,7 +402,7 @@ $hostDiscoveryRules = API::DiscoveryRule()->get(array( 'inherited' => false, 'hostids' => $_REQUEST['hostid'], - 'output' => API_OUTPUT_EXTEND + 'output' => array('name', 'key_') )); if (!empty($hostDiscoveryRules)) { $discoveryRuleList = array(); @@ -428,7 +423,7 @@ 'hostids' => $_REQUEST['hostid'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name', 'key_') )); if (!empty($hostItemPrototypes)) { $prototypeList = array(); @@ -448,8 +443,8 @@ 'hostids' => $_REQUEST['hostid'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, - 'output' => API_OUTPUT_EXTEND, - 'selectItems' => API_OUTPUT_EXTEND + 'output' => array('name', 'key_'), + 'selectItems' => array('name', 'key_') )); if (!empty($hostTriggerPrototypes)) { $prototypeList = array(); @@ -476,8 +471,8 @@ 'hostids' => $_REQUEST['hostid'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, - 'selectHosts' => API_OUTPUT_EXTEND, - 'output' => API_OUTPUT_EXTEND + 'selectHosts' => API_OUTPUT_SHORTEN, + 'output' => array('graphid', 'name') )); if (!empty($hostGraphPrototypes)) { $prototypeList = array(); Index: include/html.inc.php =================================================================== --- include/html.inc.php (revision 32355) +++ include/html.inc.php (working copy) @@ -303,7 +303,7 @@ $options = array( 'hostids' => $hostid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('hostid', 'name', 'proxy_hostid', 'status', 'error', 'available', 'snmp_available', 'snmp_error', 'jmx_available', 'jmx_error', 'ipmi_available', 'ipmi_error'), 'templated_hosts' => true ); if (isset($elements['items'])) { Index: templates.php =================================================================== --- templates.php (revision 32355) +++ templates.php (working copy) @@ -85,13 +85,21 @@ // PERMISSIONS if(get_request('groupid', 0) > 0){ - $groupids = available_groups($_REQUEST['groupid'], 1); - if(empty($groupids)) access_deny(); + $group = API::Hostgroup()->get(array('output' => array('name'), 'groupids' => array(get_request('groupid', 0)), 'editable' => true)); + if (!count($group)) { + access_deny(); + } + + $group = reset($group); } if(get_request('templateid', 0) > 0){ - $hostids = available_hosts($_REQUEST['templateid'], 1); - if(empty($hostids)) access_deny(); + $host = API::Template()->get(array('output' => array('name'), 'templateids' => array(get_request('templateid', 0)), 'editable' => true)); + if (!count($host)) { + access_deny(); + } + + $host = reset($host); } @@ -204,7 +212,7 @@ } $newgroup = API::HostGroup()->get(array( 'groupids' => $result['groupids'], - 'output' => API_OUTPUT_EXTEND + 'output' => API_OUTPUT_SHORTEN )); if ($newgroup) { $groups = array_merge($groups, $newgroup); @@ -406,23 +414,10 @@ $template_wdgt = new CWidget(); -$options = array( - 'config' => array( - 'individual' => 1 - ), - 'groups' => array( - 'templated_hosts' => 1, - 'editable' => 1, - ), - 'groupid' => get_request('groupid', null), -); -$pageFilter = new CPageFilter($options); -$_REQUEST['groupid'] = $pageFilter->groupid; - if (isset($_REQUEST['form'])) { $template_wdgt->addPageHeader(_('CONFIGURATION OF TEMPLATES')); - if ($templateid = get_request('templateid', 0)) { + if ($templateid = get_request('templateid', null)) { $template_wdgt->addItem(get_header_host_table('', $templateid)); } @@ -430,6 +425,19 @@ $template_wdgt->addItem($templateForm->render()); } else { + $options = array( + 'config' => array( + 'individual' => true + ), + 'groups' => array( + 'templated_hosts' => true, + 'editable' => true, + ), + 'groupid' => get_request('groupid', null), + ); + $pageFilter = new CPageFilter($options); + $_REQUEST['groupid'] = $pageFilter->groupid; + $frmForm = new CForm(); $frmForm->cleanItems(); @@ -475,7 +483,7 @@ if ($pageFilter->groupsSelected) { $options = array( - 'editable' => 1, + 'editable' => true, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => ($config['search_limit']+1) @@ -493,8 +501,8 @@ $options = array( 'templateids' => zbx_objectValues($templates, 'templateid'), - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND, + 'editable' => true, + 'output' => array('templateid', 'name', 'host', 'proxy_hostid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), 'selectParentTemplates' => array('hostid', 'name', 'status'), @@ -504,7 +512,7 @@ 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, - 'nopermissions' => 1, + 'nopermissions' => true, ); $templates = API::Template()->get($options); @@ -513,10 +521,7 @@ foreach($templates as $tnum => $template){ $templates_output = array(); - if($template['proxy_hostid']){ - $proxy = get_host_by_hostid($template['proxy_hostid']); - $templates_output[] = $proxy['host'].':'; - } + $templates_output[] = new CLink($template['name'], 'templates.php?form=update&templateid='.$template['templateid'].url_param('groupid')); $applications = array(new CLink(_('Applications'), 'applications.php?groupid='.$_REQUEST['groupid'].'&hostid='.$template['templateid']), Index: items.php =================================================================== --- items.php (revision 32355) +++ items.php (working copy) @@ -208,6 +208,7 @@ 'editable' => true, 'preservekeys' => true )); + if (empty($item)) { access_deny(); } @@ -215,13 +216,17 @@ elseif (get_request('hostid', 0) > 0) { $hosts = API::Host()->get(array( 'hostids' => $_REQUEST['hostid'], - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name'), 'templated_hosts' => true, 'editable' => true )); + if (empty($hosts)) { access_deny(); } + + $hostid = reset($hosts); + $hostid = $hostid['hostid']; } // ajax @@ -308,10 +313,18 @@ $_REQUEST['filter_ipmi_sensor'] = CProfile::get('web.items.filter_ipmi_sensor'); } -if (isset($_REQUEST['filter_hostname']) && !zbx_empty($_REQUEST['filter_hostname'])) { - $hostid = API::Host()->getObjects(array('name' => $_REQUEST['filter_hostname'])); +if (isset($_REQUEST['filter_hostname']) && !zbx_empty($_REQUEST['filter_hostname']) && !isset($hostid)) { + $hostid = API::Host()->get(array('filter' => array('name' => $_REQUEST['filter_hostname'] + ), + 'nopermissions' => true, + 'output' => API_OUTPUT_REFER + )); if (empty($hostid)) { - $hostid = API::Template()->getObjects(array('name' => $_REQUEST['filter_hostname'])); + $hostid = API::Template()->get(array('filter' => array('name' => $_REQUEST['filter_hostname'] + ), + 'nopermissions' => true, + 'output' => API_OUTPUT_REFER + )); } $hostid = reset($hostid); $hostid = $hostid ? $hostid['hostid'] : 0; @@ -770,7 +783,7 @@ else { // group $data['groups'] = API::HostGroup()->get(array( - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') )); order_result($data['groups'], 'name'); @@ -783,7 +796,7 @@ } $data['hosts'] = API::Host()->get(array( - 'output' => API_OUTPUT_EXTEND, + 'output' => array('host'), 'groupids' => $data['copy_groupid'], 'templated_hosts' => true )); @@ -811,12 +824,12 @@ // items $options = array( 'search' => array(), - 'output' => API_OUTPUT_EXTEND, + 'output' => array('itemid', 'name', 'key_', 'hostid', 'delay', 'status', 'history', 'trends', 'type', 'value_type', 'templateid', 'error', 'flags'), 'editable' => true, - 'selectHosts' => API_OUTPUT_EXTEND, + 'selectHosts' => array('name'), 'selectTriggers' => API_OUTPUT_REFER, 'selectApplications' => API_OUTPUT_EXTEND, - 'selectDiscoveryRule' => API_OUTPUT_EXTEND, + 'selectDiscoveryRule' => array('name'), 'selectItemDiscovery' => array('ts_delete'), 'sortfield' => $data['sortfield'], 'limit' => $config['search_limit'] + 1 @@ -993,10 +1006,10 @@ } $data['itemTriggers'] = API::Trigger()->get(array( 'triggerids' => $itemTriggerIds, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('triggerid', 'description', 'expression', 'templateid', 'status', 'priority', 'value_flags', 'flags'), 'selectHosts' => array('hostid', 'name', 'host'), 'selectFunctions' => API_OUTPUT_EXTEND, - 'selectItems' => API_OUTPUT_EXTEND, + 'selectItems' => array('itemid', 'key_', 'hostid', 'type', 'flags', 'status'), 'preservekeys' => true )); $data['triggerRealHosts'] = getParentHostsByTriggers($data['itemTriggers']); Index: hosts.php =================================================================== --- hosts.php (revision 32355) +++ hosts.php (working copy) @@ -108,16 +108,20 @@ * Permissions */ if (get_request('groupid', 0) > 0) { - $groupids = available_groups($_REQUEST['groupid'], 1); - if (empty($groupids)) { - access_deny(); - } + $group = API::Hostgroup()->get(array('output' => array('name'), 'groupids' => array(get_request('groupid', 0)), 'editable' => true)); + if (!count($group)) { + access_deny(); + } + + $group = reset($group); } if (get_request('hostid', 0) > 0) { - $hostids = available_hosts($_REQUEST['hostid'], 1); - if (empty($hostids)) { - access_deny(); - } + $host = API::Host()->get(array('output' => array('name'), 'hostids' => array(get_request('hostid', 0)), 'editable' => true)); + if (!count($host)) { + access_deny(); + } + + $host = reset($host); } /* @@ -407,7 +411,7 @@ $host_old = API::Host()->get(array( 'hostids' => $hostid, 'editable' => true, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') )); $host_old = reset($host_old); @@ -418,7 +422,7 @@ $host_new = API::Host()->get(array( 'hostids' => $hostid, 'editable' => true, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') )); $host_new = reset($host_new); @@ -555,17 +559,6 @@ */ $hosts_wdgt = new CWidget(); -$pageFilter = new CPageFilter(array( - 'groups' => array( - 'real_hosts' => 1, - 'editable' => true - ), - 'groupid' => get_request('groupid', null) -)); - -$_REQUEST['groupid'] = $pageFilter->groupid; -$_REQUEST['hostid'] = get_request('hostid', 0); - if ($_REQUEST['go'] == 'massupdate' && isset($_REQUEST['hosts'])) { $hosts_wdgt->addPageHeader(_('CONFIGURATION OF HOSTS')); @@ -592,20 +585,19 @@ // get groups $data['all_groups'] = API::HostGroup()->get(array( - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name'), 'editable' => true )); order_result($data['all_groups'], 'name'); // get proxies - $data['proxies'] = DBfetchArray(DBselect( - 'SELECT h.hostid,h.host'. - ' FROM hosts h'. - ' WHERE h.status IN ('.HOST_STATUS_PROXY_ACTIVE.','.HOST_STATUS_PROXY_PASSIVE.')'. - ' AND '.DBin_node('h.hostid'). - ' ORDER BY h.host' - )); + $data['proxies'] = API::Proxy()->get(array('nodeids' => get_current_nodeid(true), + 'output' => array('host'), + 'preserve_keys' => true + )); + order_result($data['proxies'], 'host'); + // get inventories if ($data['inventory_mode'] != HOST_INVENTORY_DISABLED) { $data['inventories'] = getHostInventories(); @@ -627,6 +619,17 @@ $hosts_wdgt->setRootClass('host-edit'); } else { + $pageFilter = new CPageFilter(array( + 'groups' => array( + 'real_hosts' => true, + 'editable' => true + ), + 'groupid' => get_request('groupid', null) + )); + + $_REQUEST['groupid'] = $pageFilter->groupid; + $_REQUEST['hostid'] = get_request('hostid', 0); + $frmForm = new CForm(); $frmForm->cleanItems(); $buttons = new CDiv(array( @@ -729,7 +732,7 @@ $hosts = API::Host()->get(array( 'hostids' => zbx_objectValues($hosts, 'hostid'), - 'output' => API_OUTPUT_EXTEND, + 'output' => array('hostid', 'name', 'proxy_hostid', 'status', 'maintenance_status', 'available', 'error', 'snmp_available', 'snmp_error', 'jmx_available', 'jmx_error', 'ipmi_available', 'ipmi_error'), 'selectParentTemplates' => array('hostid', 'name'), 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectItems' => API_OUTPUT_COUNT, @@ -753,6 +756,8 @@ )); $templates = zbx_toHash($templates, 'templateid'); + $proxies = array(); + foreach ($hosts as $host) { $interface = reset($host['interfaces']); @@ -769,12 +774,16 @@ $description = array(); if ($host['proxy_hostid']) { - $proxy = API::Proxy()->get(array( - 'proxyids' => $host['proxy_hostid'], - 'output' => API_OUTPUT_EXTEND - )); - $proxy = reset($proxy); - $description[] = $proxy['host'].':'; + if (!isset($proxies[$host['proxy_hostid']])) { + $proxy = API::Proxy()->get(array( + 'proxyids' => $host['proxy_hostid'], + 'output' => array('host') + )); + $proxies[$host['proxy_hostid']] = reset($proxy); + } + + + $description[] = $proxies[$host['proxy_hostid']]['host'].':'; } $description[] = new CLink($host['name'], 'hosts.php?form=update&hostid='.$host['hostid'].url_param('groupid')); Index: triggers.php =================================================================== --- triggers.php (revision 32355) +++ triggers.php (working copy) @@ -101,11 +101,11 @@ elseif (get_request('hostid', 0) > 0) { $hosts = API::Host()->get(array( 'hostids' => $_REQUEST['hostid'], - 'output' => API_OUTPUT_EXTEND, + 'countOutput' => true, 'templated_hosts' => true, 'editable' => true )); - if (empty($hosts)) { + if (!count($hosts)) { access_deny(); } } @@ -299,7 +299,7 @@ 'triggerids' => $triggerIdsToUpdate, 'output' => array('triggerid', 'description'), 'preservekeys' => true, - 'selectHosts' => API_OUTPUT_EXTEND, + 'selectHosts' => array('host'), 'nopermissions' => true )); foreach ($db_triggers as $triggerid => $trigger) { @@ -423,12 +423,12 @@ $data['triggers'] = API::Trigger()->get(array( 'triggerids' => zbx_objectValues($data['triggers'], 'triggerid'), - 'output' => API_OUTPUT_EXTEND, - 'selectHosts' => API_OUTPUT_EXTEND, - 'selectItems' => API_OUTPUT_EXTEND, + 'output' => array('triggerid', 'description', 'expression', 'status', 'value_flags', 'priority', 'templateid', 'error'), + 'selectHosts' => array('hostid', 'host', 'name', 'status'), + 'selectItems' => array('itemid', 'key_', 'status', 'hostid', 'type', 'flags'), 'selectFunctions' => API_OUTPUT_EXTEND, 'selectDependencies' => API_OUTPUT_EXTEND, - 'selectDiscoveryRule' => API_OUTPUT_EXTEND + 'selectDiscoveryRule' => array('itemid', 'name') )); order_result($data['triggers'], $sortfield, getPageSortOrder()); Index: hostgroups.php =================================================================== --- hostgroups.php (revision 32355) +++ hostgroups.php (working copy) @@ -55,10 +55,12 @@ // validate permissions if (get_request('groupid', 0) > 0) { - $groupids = available_groups($_REQUEST['groupid'], 1); - if (empty($groupids)) { + $group = API::Hostgroup()->get(array('output' => array('name', 'internal'), 'groupids' => array($_REQUEST['groupid']), 'editable' => true)); + if (!count($group)) { access_deny(); } + + $group = reset($group); } /* @@ -81,11 +83,7 @@ if (!empty($_REQUEST['groupid'])) { DBstart(); - $old_group = API::HostGroup()->get(array( - 'groupids' => $_REQUEST['groupid'], - 'output' => API_OUTPUT_EXTEND - )); - $old_group = reset($old_group); + $old_group = $group; $result = API::HostGroup()->update(array( 'groupid' => $_REQUEST['groupid'], @@ -95,7 +93,7 @@ if ($result) { $options = array( 'groupids' => $result['groupids'], - 'output' => API_OUTPUT_EXTEND + 'output' => API_OUTPUT_SHORTEN ); $groups = API::HostGroup()->get($options); @@ -124,7 +122,7 @@ if ($result) { $options = array( 'groupids' => $result['groupids'], - 'output' => API_OUTPUT_EXTEND + 'output' => API_OUTPUT_SHORTEN ); $groups = API::HostGroup()->get($options); @@ -172,8 +170,8 @@ DBstart(); $hosts = API::Host()->get(array( 'groupids' => $groups, - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND + 'editable' => true, + 'output' => array('hostid', 'name', 'status') )); if (empty($hosts)) { @@ -212,7 +210,7 @@ $data['name'] = get_request('name', ''); $data['twb_groupid'] = get_request('twb_groupid', -1); if ($data['groupid'] > 0) { - $data['group'] = get_hostgroup_by_groupid($data['groupid']); + $data['group'] = $group; // if first time select all hosts for group from db if (!isset($_REQUEST['form_refresh'])) { @@ -220,7 +218,7 @@ $options = array( 'groupids' => $data['groupid'], - 'templated_hosts' => 1, + 'templated_hosts' => true, 'output' => API_OUTPUT_SHORTEN ); $data['hosts'] = API::Host()->get($options); @@ -231,10 +229,10 @@ // get all possible groups $options = array( - 'not_proxy_host' => 1, + 'not_proxy_host' => true, 'sortfield' => 'name', 'editable' => true, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') ); $data['db_groups'] = API::HostGroup()->get($options); @@ -243,47 +241,39 @@ $data['twb_groupid'] = $gr['groupid']; } - if ($data['twb_groupid'] == 0) { - // get all hosts from all groups - $options = array( - 'templated_hosts' => 1, - 'sortfield' => 'name', - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND - ); - } - else { + $options = array( + 'templated_hosts' => true, + 'sortfield' => 'name', + 'editable' => true, + 'output' => array('name') + ); + + if ($data['twb_groupid'] != 0) { // get hosts from selected twb_groupid combo - $options = array( - 'groupids' => $data['twb_groupid'], - 'templated_hosts' => 1, - 'sortfield' => 'name', - 'editable' => 1, - 'output' => API_OUTPUT_EXTEND - ); + $options['groupids'] = $data['twb_groupid']; } $data['db_hosts'] = API::Host()->get($options); // get selected hosts $options = array( 'hostids' => $data['hosts'], - 'templated_hosts' => 1, + 'templated_hosts' => true, 'sortfield' => 'name', - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') ); $data['r_hosts'] = API::Host()->get($options); // get hosts ids $options = array( 'hostids' => $data['hosts'], - 'templated_hosts' =>1, - 'editable' => 1, + 'templated_hosts' => true, + 'editable' => true, 'output' => API_OUTPUT_SHORTEN ); $data['rw_hosts'] = API::Host()->get($options); $data['rw_hosts'] = zbx_toHash($data['rw_hosts'], 'hostid'); - if (!empty($data['groupid'])) { + if (!empty($data['groupid']) && $group['internal'] != true) { $data['deletableHostGroups'] = getDeletableHostGroups($data['groupid']); } @@ -298,7 +288,7 @@ $sortfield = getPageSortField('name'); $sortorder = getPageSortOrder(); $options = array( - 'editable' => 1, + 'editable' => true, 'output' => API_OUTPUT_SHORTEN, 'sortfield' => $sortfield, 'limit' => $config['search_limit'] + 1 @@ -312,7 +302,7 @@ 'groupids' => zbx_objectValues($groups, 'groupid'), 'selectHosts' => API_OUTPUT_COUNT, 'selectTemplates' => API_OUTPUT_COUNT, - 'nopermissions' => 1 + 'nopermissions' => true ); $data['groupCounts'] = API::HostGroup()->get($options); $data['groupCounts'] = zbx_toHash($data['groupCounts'], 'groupid'); @@ -322,8 +312,8 @@ 'groupids' => zbx_objectValues($groups, 'groupid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), - 'output' => API_OUTPUT_EXTEND, - 'nopermissions' => 1, + 'output' => array('name'), + 'nopermissions' => true, 'limitSelects' => $config['max_in_table'] + 1 ); $data['groups'] = API::HostGroup()->get($options); Index: api/classes/CItem.php =================================================================== --- api/classes/CItem.php (revision 32362) +++ api/classes/CItem.php (working copy) @@ -636,6 +636,7 @@ foreach ($applications as $application) { $aitems = $application['items']; unset($application['items']); + $application['hosts'] = zbx_toHash($application['hosts'], 'hostid'); foreach ($aitems as $item) { $result[$item['itemid']]['applications'][] = $application; }