diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-12-22 10:04:06 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-12-22 10:04:06 +0000 |
commit | da7c9d797a97c882f032b3860268970217b36a15 (patch) | |
tree | 092e2908d6bc08d3711908a3ef05175bb11a235d /frontends/php/include | |
parent | 68cc73b3adbfe688b31a24e9b6df658aab849218 (diff) | |
download | zabbix-da7c9d797a97c882f032b3860268970217b36a15.tar.gz zabbix-da7c9d797a97c882f032b3860268970217b36a15.tar.xz zabbix-da7c9d797a97c882f032b3860268970217b36a15.zip |
- fixed SQL statements for PostgreSQL (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3634 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r-- | frontends/php/include/export.inc.php | 4 | ||||
-rw-r--r-- | frontends/php/include/perm.inc.php | 19 |
2 files changed, 15 insertions, 8 deletions
diff --git a/frontends/php/include/export.inc.php b/frontends/php/include/export.inc.php index 73454901..6f9ff48f 100644 --- a/frontends/php/include/export.inc.php +++ b/frontends/php/include/export.inc.php @@ -309,7 +309,7 @@ zbx_xmlwriter_start_element ($memory,XML_TAG_TRIGGERS); $db_triggers = DBselect('select f.triggerid, i.hostid, count(distinct i.hostid) as cnt '. ' from functions f, items i '. - ' where f.itemid=i.itemid group by f.triggerid'); + ' where f.itemid=i.itemid group by f.triggerid, i.hostid'); while($trigger = DBfetch($db_triggers)) { if($trigger['hostid'] != $hostid || $trigger['cnt']!=1) continue; @@ -322,7 +322,7 @@ zbx_xmlwriter_start_element ($memory, XML_TAG_GRAPHS); $db_graphs = DBselect('select gi.graphid, i.hostid, count(distinct i.hostid) as cnt '. ' from graphs_items gi, items i '. - ' where gi.itemid=i.itemid group by gi.graphid'); + ' where gi.itemid=i.itemid group by gi.graphid, i.hostid'); while($graph = DBfetch($db_graphs)) { if($graph['hostid'] != $hostid || $graph['cnt']!=1) continue; diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php index d82bfc66..3aaa1160 100644 --- a/frontends/php/include/perm.inc.php +++ b/frontends/php/include/perm.inc.php @@ -175,17 +175,19 @@ COpt::counter_up('perm'); $where.' group by h.hostid'. ' order by n.name,n.nodeid, g.name, h.host');*/ - $db_hosts = DBselect('select distinct n.nodeid,n.name as node_name,h.*, min(r.permission) as permission '. + $db_hosts = DBselect('select distinct n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission '. ' from hosts h left join hosts_groups hg on hg.hostid=h.hostid '. ' left join groups g on g.groupid=hg.groupid '. ' left join rights r on r.id=g.groupid and r.type='.RESOURCE_TYPE_GROUP. ' left join users_groups ug on ug.userid='.$userid. ' left join nodes n on '.DBid2nodeid('h.hostid').'=n.nodeid '. - $where.' group by h.hostid'. - ' order by n.name,n.nodeid, g.name, h.host'); + $where.' group by h.hostid,n.nodeid,n.name,h.host '. + ' order by n.name,n.nodeid, h.host'); while($host_data = DBfetch($db_hosts)) { + $host_data += DBfetch(DBselect('select * from hosts where hostid='.$host_data['hostid'])); + if(is_null($host_data['nodeid'])) $host_data['nodeid'] = id2nodeid($host_data['hostid']); /* if no rights defined used node rights */ @@ -257,11 +259,11 @@ COpt::counter_up('perm'); $where.' group by hg.groupid, hg.name, g.userid '. ' order by n.name, hg.name');*/ - $db_groups = DBselect('select n.nodeid as nodeid,n.name as node_name,hg.*, min(r.permission) as permission '. + $db_groups = DBselect('select n.nodeid as nodeid,n.name as node_name,hg.groupid,hg.name, min(r.permission) as permission '. ' from groups hg left join rights r on r.id=hg.groupid and r.type='.RESOURCE_TYPE_GROUP. ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid. ' left join nodes n on '.DBid2nodeid('hg.groupid').'=n.nodeid '. - $where.' group by hg.groupid, hg.name, g.userid '. + $where.' group by n.nodeid, n.name, hg.groupid, hg.name, g.userid '. ' order by n.name, hg.name'); while($group_data = DBfetch($db_groups)) @@ -331,13 +333,18 @@ COpt::counter_up('perm'); ' right join nodes n on r.id=n.nodeid'.$where_nodeid. ' group by n.nodeid');*/ - $db_nodes = DBselect('select n.*,min(r.permission) as permission'. + $db_nodes = DBselect('select n.nodeid,min(r.permission) as permission'. ' from nodes n left join rights r on r.id=n.nodeid and r.type='.RESOURCE_TYPE_NODE. ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid. $where_nodeid.' group by n.nodeid'); while(($node_data = DBfetch($db_nodes)) || (!isset($do_break) && !ZBX_DISTRIBUTED)) { + if($node_data && $perm_res == PERM_RES_DATA_ARRAY) + { + $node_data += DBfetch(DBselect('select * from nodes where nodeid='.$node_data['nodeid'])); + } + if(!ZBX_DISTRIBUTED) { if(!$node_data) |