summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/triggers.inc.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-30 15:58:48 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-01-30 15:58:48 +0000
commite3693c12ab9e2bf934e1cb8194c1be5fe3650d86 (patch)
tree6d3ce9d0adf5ff71f0d4f4415a4a9854651840d8 /frontends/php/include/triggers.inc.php
parent042eb9179036479789a63b7eda13c84734a741e7 (diff)
downloadzabbix-e3693c12ab9e2bf934e1cb8194c1be5fe3650d86.tar.gz
zabbix-e3693c12ab9e2bf934e1cb8194c1be5fe3650d86.tar.xz
zabbix-e3693c12ab9e2bf934e1cb8194c1be5fe3650d86.zip
- fixed permissions for triggers (Eugene)
- developed 'mass update' functionality for items (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@3772 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/triggers.inc.php')
-rw-r--r--frontends/php/include/triggers.inc.php66
1 files changed, 28 insertions, 38 deletions
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index 7b605bf8..c43ef729 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -122,35 +122,12 @@
$state='HOST';
continue;
}
-
- if($expression[$i] == '}' && $state=="")
- {
- $state='';
- $hosts[$host] = '\''.$host.'\'';
- continue;
- }
- if($expression[$i] == '(' && $state == "FUNCTION")
- {
- $state='PARAMETER';
- continue;
- }
-
- if($expression[$i] == ')' && $state == "PARAMETER")
- {
- $state='';
- continue;
- }
-
if($expression[$i] == ':' && $state == "HOST")
{
- $state="KEY";
- continue;
- }
-
- if($expression[$i] == '.' && ($state == "KEY" || $state == "FUNCTION"))
- {
- $state="FUNCTION";
+ $state="";
+ $hosts[$host] = '\''.$host.'\'';
+ $host = '';
continue;
}
@@ -159,11 +136,9 @@
$host .= $expression[$i];
continue;
}
- if($state == "KEY" || $state == "FUNCTION" || $state == "PARAMETER")
- continue;
}
- if(count($hosts) == 0) $hosts = array('');
+ if(count($hosts) == 0) $hosts = array('0');
return DBselect('select distinct * from hosts where '.DBid2nodeid('hostid').'='.$ZBX_CURNODEID.
' and host in ('.implode(',',$hosts).')');
@@ -891,16 +866,31 @@
return $result;
}
- function check_right_on_trigger($permission,$triggerid) /* TODO */
+ function check_right_on_trigger_by_triggerid($permission,$triggerid,$accessible_hosts=null)
{
- /*
- $result=DBselect("select distinct h.hostid from functions f,items i,hosts h".
- " where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid");
- while($row=DBfetch($result))
- if(check_right("Host",$permission,$row["hostid"]))
- return 1;
- */
- return 0;
+ $trigger_data = DBfetch(DBselect('select expression from triggers where triggerid='.$triggerid));
+
+ if(!$trigger_data) return false;
+
+ return check_right_on_trigger_by_expression($permission, explode_exp($trigger_data['expression'], 0), $accessible_hosts);
+ }
+
+ function check_right_on_trigger_by_expression($permission,$expression,$accessible_hosts=null)
+ {
+ if(is_null($accessible_hosts))
+ {
+ global $USER_DETAILS;
+ $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, $permission, null, PERM_RES_IDS_ARRAY);
+ }
+ if(!is_array($accessible_hosts)) $accessible_hosts = explode(',', $accessible_hosts);
+
+ $db_hosts = get_hosts_by_expression($expression);
+ while($host_data = DBfetch($db_hosts))
+ {
+ if(!in_array($host_data['hostid'], $accessible_hosts)) return false;
+ }
+
+ return true;
}
function delete_dependencies_by_triggerid($triggerid)