summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/perm.inc.php
diff options
context:
space:
mode:
authoralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-23 09:52:07 +0000
committeralex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-23 09:52:07 +0000
commit1a165dee80300c9ce148be4fa717c5f5d4b1908c (patch)
tree3239bb311be451dad74822c304b0ea01d5dcc4f2 /frontends/php/include/perm.inc.php
parentd6a68d74d0daec16b48a3adc42db3b1c4319cfb3 (diff)
downloadzabbix-1a165dee80300c9ce148be4fa717c5f5d4b1908c.tar.gz
zabbix-1a165dee80300c9ce148be4fa717c5f5d4b1908c.tar.xz
zabbix-1a165dee80300c9ce148be4fa717c5f5d4b1908c.zip
- fied permission system for groups with multiple uers (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@4161 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/perm.inc.php')
-rw-r--r--frontends/php/include/perm.inc.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index bce0d3d5..c0351b5f 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -173,8 +173,9 @@ COpt::counter_up('perm');
' left join users_groups ug on ug.usrgrpid=r.groupid and ug.userid='.$userid.
' left join nodes n on '.DBid2nodeid('h.hostid').'=n.nodeid '.
$where.' group by h.hostid,n.nodeid,n.name,h.host,ug.userid '.
- ' order by n.name,n.nodeid, h.host, permission desc');
+ ' order by n.name,n.nodeid, h.host, permission desc, userid desc');
+ $processed = array();
while($host_data = DBfetch($db_hosts))
{
$host_data += DBfetch(DBselect('select * from hosts where hostid='.$host_data['hostid']));
@@ -182,8 +183,11 @@ COpt::counter_up('perm');
if(is_null($host_data['nodeid'])) $host_data['nodeid'] = id2nodeid($host_data['hostid']);
/* if no rights defined used node rights */
- if(is_null($host_data['permission']) || is_null($host_data['userid']))
+ if( (is_null($host_data['permission']) || is_null($host_data['userid'])) )
{
+ if( isset($processed[$host_data['hostid']]) )
+ continue;
+
if(!isset($nodes))
{
$nodes = get_accessible_nodes_by_user($user_data,
@@ -195,12 +199,16 @@ COpt::counter_up('perm');
$host_data['permission'] = $nodes[$host_data['nodeid']]['permission'];
}
+ $processed[$host_data['hostid']] = true;
+
if(eval('return ('.$host_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
continue;
$result[$host_data['hostid']] = eval('return '.$resdata.';');
}
+ unset($processed, $host_data, $db_hosts);
+
if($perm_res == PERM_RES_STRING_LINE)
{
if(count($result) == 0)
@@ -250,13 +258,17 @@ COpt::counter_up('perm');
$where.' group by n.nodeid, n.name, hg.groupid, hg.name, g.userid, g.userid '.
' order by n.name, hg.name, permission desc');
+ $processed = array();
while($group_data = DBfetch($db_groups))
{
if(is_null($group_data['nodeid'])) $group_data['nodeid'] = id2nodeid($group_data['groupid']);
/* deny if no rights defined */
- if(is_null($group_data['permission']) || is_null($group_data['userid']))
+ if( is_null($group_data['permission']) || is_null($group_data['userid']) )
{
+ if(isset($processed[$group_data['groupid']]))
+ continue;
+
if(!isset($nodes))
{
$nodes = get_accessible_nodes_by_user($user_data,
@@ -269,12 +281,16 @@ COpt::counter_up('perm');
$group_data['permission'] = $nodes[$group_data['nodeid']]['permission'];
}
+ $processed[$group_data['permission']] = true;
+
if(eval('return ('.$group_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
continue;
$result[$group_data['groupid']] = eval('return '.$resdata.';');
}
+ unset($processed, $group_data, $db_groups);
+
if($perm_res == PERM_RES_STRING_LINE)
{
if(count($result) == 0)