Index: popup.php =================================================================== --- popup.php (revision 32362) +++ popup.php (working copy) @@ -301,17 +301,29 @@ * Page filter */ if (!empty($group)) { - $dbGroup = DBfetch(DBselect('SELECT g.groupid FROM groups g WHERE g.name='.zbx_dbstr($group))); - if (!empty($dbGroup) && !empty($dbGroup['groupid'])) { + $dbGroup = API::Hostgroup()->get(array('output' => API_OUTPUT_REFER, + 'filter' => array('name' => $group), + 'nopermissions' => true, + 'preserve_keys' => true + )); + if (isset($dbGroup)) { + $dbGroup = reset($dbGroup); $_REQUEST['groupid'] = $dbGroup['groupid']; } + unset($dbGroup); } if (!empty($host)) { - $dbHost = DBfetch(DBselect('SELECT h.hostid FROM hosts h WHERE h.name='.zbx_dbstr($host))); - if (!empty($dbHost) && !empty($dbHost['hostid'])) { + $dbHost = API::Host()->get(array('output' => API_OUTPUT_REFER, + 'filter' => array('name' => $group), + 'nopermissions' => true, + 'preserve_keys' => true + )); + if (isset($dbHost)) { + $dbHost = reset($dbHost); $_REQUEST['hostid'] = $dbHost['hostid']; } + unset($dbHost); } @@ -635,7 +647,7 @@ $options = array( 'nodeids' => $nodeid, 'groupids' => $groupid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('hostid', 'name'), 'sortfield' => 'name' ); if (!is_null($writeonly)) { @@ -1103,7 +1115,7 @@ 'nodeids' => $nodeid, 'hostids' => $hostid, 'webitems' => true, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('itemid', 'name', 'key_', 'status', 'type', 'value_type'), 'selectHosts' => array('hostid', 'name'), 'preservekeys' => true ); @@ -1221,7 +1233,7 @@ 'nodeids' => $nodeid, 'selectHosts' => array('name'), 'discoveryids' => get_request('parent_discoveryid'), - 'output' => API_OUTPUT_EXTEND, + 'output' => array('itemid', 'name', 'key_', 'status', 'type', 'value_type'), 'preservekeys' => true )); order_result($items, 'name'); @@ -1364,9 +1376,9 @@ } $options = array( 'hostids' => $hostid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('graphid', 'name', 'graphtype'), 'nodeids' => $nodeid, - 'selectHosts' => API_OUTPUT_EXTEND, + 'selectHosts' => array('hostid', 'name'), 'preservekeys' => true ); @@ -1462,8 +1474,8 @@ $options = array( 'nodeids' => $nodeid, 'hostids' => $hostid, - 'output' => API_OUTPUT_EXTEND, - 'selectHosts' => API_OUTPUT_EXTEND, + 'output' => array('itemid', 'name', 'key_', 'type', 'value_type'), + 'selectHosts' => array('hostid', 'name'), 'webitems' => true, 'templated' => false, 'filter' => array( @@ -1572,7 +1584,7 @@ $options = array( 'nodeids' => $nodeid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('name'), 'preservekeys' => true ); if (!is_null($writeonly)) { @@ -1636,8 +1648,8 @@ $options = array( 'nodeids' => $nodeid, 'hostids' => $hostid, - 'output' => API_OUTPUT_EXTEND, - 'selectHosts' => API_OUTPUT_EXTEND, + 'output' => array('itemid', 'name', 'key_', 'status', 'type', 'value_type'), + 'selectHosts' => array('hostid', 'name'), 'templated' => 0, 'filter' => array('status' => ITEM_STATUS_ACTIVE), 'sortfield' => 'name' @@ -1754,7 +1766,7 @@ $options = array( 'nodeids' => $nodeid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('screenid', 'name'), 'preservekeys' => true ); $screens = API::Screen()->get($options); @@ -1803,7 +1815,7 @@ $options = array( 'nodeids' => $nodeid, - 'output' => API_OUTPUT_EXTEND + 'output' => array('screenid', 'name'), ); $screens = API::Screen()->get($options); order_result($screens, 'name'); @@ -1835,7 +1847,7 @@ $options = array( 'nodeids' => $nodeid, 'monitored_hosts' => true, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name'), ); if (!is_null($writeonly)) { $options['editable'] = true; @@ -1865,7 +1877,7 @@ $options = array( 'nodeids' => $nodeid, - 'output' => API_OUTPUT_EXTEND + 'output' => array('name') ); if (!is_null($writeonly)) { $options['editable'] = true; @@ -1903,10 +1915,13 @@ $table = new CTableInfo(_('No discovery rules defined.')); $table->setHeader(_('Name')); - $result = DBselect('SELECT DISTINCT d.* FROM drules d WHERE '.DBin_node('d.druleid', $nodeid)); - while ($row = DBfetch($result)) { - $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''); - $name = new CSpan($row['name'], 'link'); + $dRules = API::DRule()->get(array( + 'nodeids' => array($nodeid), + 'output' => API_OUTPUT_EXTEND + )); + foreach($dRules as $dRule) { + $action = get_window_opener($dstfrm, $dstfld1, $dRule[$srcfld1]).(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $dRule[$srcfld2]) : ''); + $name = new CSpan($dRule['name'], 'link'); $name->setAttribute('onclick', $action.' close_window(); return false;'); $table->addRow($name); } @@ -1942,16 +1957,12 @@ $table = new CTableInfo(_('No proxies defined.')); $table->setHeader(_('Name')); - $result = DBselect( - 'SELECT DISTINCT h.hostid,h.host'. - ' FROM hosts h'. - ' WHERE '.DBin_node('h.hostid', $nodeid). - ' AND h.status IN ('.HOST_STATUS_PROXY_ACTIVE.','.HOST_STATUS_PROXY_PASSIVE.')'. - ' ORDER BY h.host,h.hostid' - ); - while ($row = DBfetch($result)) { - $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''); - $name = new CSpan($row['host'], 'link'); + $proxies = API::Proxy()->get(array('output' => array('host'))); + order_result($proxies, 'host'); + foreach ($proxies as $proxy) { + $proxy['hostid'] = $proxy['proxyid']; + $action = get_window_opener($dstfrm, $dstfld1, $proxy[$srcfld1]).(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $proxy[$srcfld2]) : ''); + $name = new CSpan($proxy['host'], 'link'); $name->setAttribute('onclick', $action.' close_window(); return false;'); $table->addRow($name); } @@ -1985,7 +1996,7 @@ $options = array( 'nodeids' => $nodeid, - 'output' => API_OUTPUT_EXTEND, + 'output' => array('scriptid', 'name', 'command', 'type', 'execute_on'), 'preservekeys' => true ); if (is_null($hostid)) {