diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-05-06 11:52:09 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-05-06 11:52:09 +0000 |
commit | 26ee00a8526a15de827768c715a0fc27a4cee925 (patch) | |
tree | e4544ad543e3d4cd1a69bc43f28aa153f44f8ebe | |
parent | 639aac687504d1c00010a4295c22f3e6fb878ffb (diff) | |
download | zabbix-26ee00a8526a15de827768c715a0fc27a4cee925.tar.gz zabbix-26ee00a8526a15de827768c715a0fc27a4cee925.tar.xz zabbix-26ee00a8526a15de827768c715a0fc27a4cee925.zip |
- better error reporting for GUI (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1757 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | frontends/php/css.css | 8 | ||||
-rw-r--r-- | frontends/php/include/actions.inc.php | 4 | ||||
-rw-r--r-- | frontends/php/include/config.inc.php | 127 | ||||
-rw-r--r-- | frontends/php/include/graphs.inc.php | 16 | ||||
-rw-r--r-- | frontends/php/include/hosts.inc.php | 22 | ||||
-rw-r--r-- | frontends/php/include/items.inc.php | 26 | ||||
-rw-r--r-- | frontends/php/include/maps.inc.php | 12 | ||||
-rw-r--r-- | frontends/php/include/screens.inc.php | 12 | ||||
-rw-r--r-- | frontends/php/include/services.inc.php | 10 | ||||
-rw-r--r-- | frontends/php/include/triggers.inc.php | 24 | ||||
-rw-r--r-- | frontends/php/include/users.inc.php | 12 |
12 files changed, 100 insertions, 174 deletions
@@ -1,5 +1,6 @@ Changes for 1.1alpha8: + - better error reporting for GUI (Alexei) - daily/weekly/monthly/yearly SLA statistics (Alexei) - added parameter ServerPort to zabbix_agentd.conf (Alexei) - added parameter RefreshActiveChecks to zabbix_agentd.conf (Alexei) diff --git a/frontends/php/css.css b/frontends/php/css.css index f5566bbc..0e933a4f 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -255,6 +255,14 @@ p.uppercase {text-transform: uppercase} p.margin {margin-left: 10pt} +p.error +{ + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 8pt; + border: 1px dashed #000000; + color:#AA0000; + background-color: #FFFFFF; +} table.home { diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 57d74467..b808a249 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -31,11 +31,9 @@ function add_action( $triggerid, $userid, $good, $delay, $subject, $message, $scope, $severity, $recipient, $usrgrpid) { - global $ERROR_MSG; - if(!check_right_on_trigger("A",$triggerid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 9afdb0b6..3ddc6d3e 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -40,6 +40,20 @@ include_once "include/services.inc.php"; include_once "include/maps.inc.php"; + function error($msg) + { + global $ERROR_MSG; + + if(is_array($ERROR_MSG)) + { + array_push($ERROR_MSG,$msg); + } + else + { + $ERROR_MSG=array($msg); + } + } + function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); @@ -583,8 +597,6 @@ function get_group_by_groupid($groupid) { - global $ERROR_MSG; - $sql="select * from groups where groupid=$groupid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -593,15 +605,13 @@ } else { - $ERROR_MSG="No groups with groupid=[$groupid]"; + error("No groups with groupid=[$groupid]"); } return $result; } function get_action_by_actionid($actionid) { - global $ERROR_MSG; - $sql="select * from actions where actionid=$actionid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -610,15 +620,13 @@ } else { - $ERROR_MSG="No action with actionid=[$actionid]"; + error("No action with actionid=[$actionid]"); } return $result; } function get_usergroup_by_usrgrpid($usrgrpid) { - global $ERROR_MSG; - $result=DBselect("select usrgrpid,name from usrgrp where usrgrpid=$usrgrpid"); if(DBnum_rows($result) == 1) { @@ -626,7 +634,7 @@ } else { - $ERROR_MSG="No user group with usrgrpid=[$usrgrpid]"; + error("No user group with usrgrpid=[$usrgrpid]"); } return $result; } @@ -647,8 +655,6 @@ function get_function_by_functionid($functionid) { - global $ERROR_MSG; - $sql="select * from functions where functionid=$functionid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -657,15 +663,13 @@ } else { - $ERROR_MSG="No function with functionid=[$functionid]"; + error("No function with functionid=[$functionid]"); } return $item; } function select_config() { - global $ERROR_MSG; - // $sql="select smtp_server,smtp_helo,smtp_email,alarm_history,alert_history from config"; $sql="select alarm_history,alert_history from config"; $result=DBselect($sql); @@ -682,7 +686,7 @@ } else { - $ERROR_MSG="Unable to select configuration"; + error("Unable to select configuration"); } return $config; } @@ -701,18 +705,20 @@ $color="#223344"; } echo "<p align=center>"; -// echo "<font size=+1 color='$color'>"; echo "<font color='$color'>"; - if($ERROR_MSG=="") - { - echo "<b>[$msg]</b>"; - } - else - { - echo "<b>[$msg. $ERROR_MSG]</b>"; - } + echo "<b>[$msg]</b>"; echo "</font>"; echo "</p>"; + + if(is_array($ERROR_MSG)) + { + echo "<p align=center class=\"error\">"; + while(list($key, $val)=each($ERROR_MSG)) + { + echo $val."<br>"; + } + echo "</p>"; + } } function show_message($msg) @@ -741,8 +747,6 @@ // Does expression match server:key.function(param) ? function validate_simple_expression($expression) { - global $ERROR_MSG; - // echo "Validating simple:$expression<br>"; // Before str() // if (eregi('^\{([0-9a-zA-Z[.-.]\_\.]+)\:([]\[0-9a-zA-Z\_\/\.\,]+)\.((diff)|(min)|(max)|(last)|(prev))\(([0-9\.]+)\)\}$', $expression, &$arr)) @@ -763,7 +767,7 @@ $result=DBselect($sql); if(DBget_field($result,0,0)!=1) { - $ERROR_MSG="No such host ($host) or monitored parameter ($key)"; + error("No such host ($host) or monitored parameter ($key)"); return -1; } @@ -785,20 +789,20 @@ ($function!="now")&& ($function!="str")) { - $ERROR_MSG="Unknown function [$function]"; + error("Unknown function [$function]"); return -1; } if(( $function!="str") && (validate_float($parameter)!=0) ) { - $ERROR_MSG="[$parameter] is not a float"; + error("[$parameter] is not a float"); return -1; } } else { - $ERROR_MSG="Expression [$expression] does not match to [server:key.func(param)]"; + error("Expression [$expression] does not match to [server:key.func(param)]"); return -1; } return 0; @@ -806,8 +810,6 @@ function validate_expression($expression) { - global $ERROR_MSG; - // echo "Validating expression: $expression<br>"; $ok=0; @@ -852,12 +854,12 @@ // } if(validate_float($arr[3])!=0) { - $ERROR_MSG="[".$arr[3]."] is not a float"; + error("[".$arr[3]."] is not a float"); return -1; } if(validate_float($arr[5])!=0) { - $ERROR_MSG="[".$arr[5]."] is not a float"; + error("[".$arr[5]."] is not a float"); return -1; } $expression=$arr[1]."(0)".$arr[6]; @@ -881,7 +883,7 @@ // } if(validate_float($arr[4])!=0) { - $ERROR_MSG="[".$arr[4]."] is not a float"; + error("[".$arr[4]."] is not a float"); return -1; } $expression=$arr[1]."0".$arr[5]; @@ -1415,10 +1417,9 @@ echo "</head>"; function update_host_status($hostid,$status) { - global $ERROR_MSG; if(!check_right("Host","U",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -1439,8 +1440,6 @@ echo "</head>"; function add_image($name,$imagetype,$files) { - global $ERROR_MSG; - if(isset($files)) { if($files["image"]["error"]==0) @@ -1452,13 +1451,13 @@ echo "</head>"; } else { - $ERROR_MSG="Image size must be less than 1Mb"; + error("Image size must be less than 1Mb"); return FALSE; } } else { - $ERROR_MSG="Select image to download"; + error("Select image to download"); return FALSE; } } @@ -1566,11 +1565,9 @@ echo "</head>"; function add_using_host_template($hostid,$host_templateid) { - global $ERROR_MSG; - if(!isset($host_templateid)||($host_templateid==0)) { - $ERROR_MSG="Select template first"; + error("Select template first"); return 0; } @@ -1680,11 +1677,9 @@ echo "</head>"; function add_host_group($name,$hosts) { - global $ERROR_MSG; - // if(!check_right("Host","A",0)) // { -// $ERROR_MSG="Insufficient permissions"; +// error("Insufficient permissions"); // return 0; // } @@ -1692,7 +1687,7 @@ echo "</head>"; $result=DBexecute($sql); if(DBnum_rows($result)>0) { - $ERROR_MSG="Group '$name' already exists"; + error("Group '$name' already exists"); return 0; } @@ -1712,11 +1707,9 @@ echo "</head>"; function add_user_group($name,$users) { - global $ERROR_MSG; - if(!check_right("Host","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -1724,7 +1717,7 @@ echo "</head>"; $result=DBexecute($sql); if(DBnum_rows($result)>0) { - $ERROR_MSG="Group '$name' already exists"; + error("Group '$name' already exists"); return 0; } @@ -1744,11 +1737,9 @@ echo "</head>"; function update_host_group($groupid,$name,$users) { - global $ERROR_MSG; - // if(!check_right("Host","U",0)) // { -// $ERROR_MSG="Insufficient permissions"; +// error("Insufficient permissions"); // return 0; // } @@ -1756,7 +1747,7 @@ echo "</head>"; $result=DBexecute($sql); if(DBnum_rows($result)>0) { - $ERROR_MSG="Group '$name' already exists"; + error("Group '$name' already exists"); return 0; } @@ -1774,11 +1765,9 @@ echo "</head>"; function update_user_group($usrgrpid,$name,$users) { - global $ERROR_MSG; - if(!check_right("Host","U",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -1786,7 +1775,7 @@ echo "</head>"; $result=DBexecute($sql); if(DBnum_rows($result)>0) { - $ERROR_MSG="Group '$name' already exists"; + error("Group '$name' already exists"); return 0; } @@ -1817,11 +1806,9 @@ echo "</head>"; # Sync host with hard-linked template function sync_host_with_template($hostid,$templateid,$items,$triggers,$actions,$graphs,$screens) { - global $ERROR_MSG; - if(!isset($templateid)||($templateid==0)) { - $ERROR_MSG="Select template first"; + error("Select template first"); return 0; } @@ -1925,8 +1912,6 @@ echo "</head>"; function get_mediatype_by_mediatypeid($mediatypeid) { - global $ERROR_MSG; - $sql="select * from media_type where mediatypeid=$mediatypeid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -1935,7 +1920,7 @@ echo "</head>"; } else { - $ERROR_MSG="No media type with with mediatypeid=[$mediatypeid]"; + error("No media type with with mediatypeid=[$mediatypeid]"); } return $item; } @@ -2024,11 +2009,9 @@ echo "</head>"; // function update_config($smtp_server,$smtp_helo,$smtp_email,$alarm_history,$alert_history) function update_config($alarm_history,$alert_history) { - global $ERROR_MSG; - if(!check_right("Configuration of Zabbix","U",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -2065,8 +2048,6 @@ echo "</head>"; function delete_user_group($usrgrpid) { - global $ERROR_MSG; - $sql="delete from users_groups where usrgrpid=$usrgrpid"; DBexecute($sql); $sql="delete from usrgrp where usrgrpid=$usrgrpid"; @@ -2077,13 +2058,11 @@ echo "</head>"; function delete_user($userid) { - global $ERROR_MSG; - $sql="select * from users where userid=$userid and alias='guest'"; $result=DBselect($sql); if(DBnum_rows($result) == 1) { - $ERROR_MSG="Cannot delete user 'guest'"; + error("Cannot delete user 'guest'"); return 0; } diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index cb642277..5d08b6ad 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -23,11 +23,9 @@ function add_graph($name,$width,$height,$yaxistype,$yaxismin,$yaxismax) { - global $ERROR_MSG; - if(!check_right("Graph","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -53,11 +51,9 @@ function update_graph($graphid,$name,$width,$height,$yaxistype,$yaxismin,$yaxismax) { - global $ERROR_MSG; - if(!check_right("Graph","U",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -87,8 +83,6 @@ function get_graphitem_by_gitemid($gitemid) { - global $ERROR_MSG; - $sql="select * from graphs_items where gitemid=$gitemid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -97,15 +91,13 @@ } else { - $ERROR_MSG="No graph item with gitemid=[$gitemid]"; + error("No graph item with gitemid=[$gitemid]"); } return $result; } function get_graph_by_graphid($graphid) { - global $ERROR_MSG; - $sql="select * from graphs where graphid=$graphid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -114,7 +106,7 @@ } else { - $ERROR_MSG="No graph with graphid=[$graphid]"; + error("No graph with graphid=[$graphid]"); } return $result; } diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index 8befe5aa..f1e399f9 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -23,17 +23,15 @@ function add_host($host,$port,$status,$useip,$ip,$host_templateid,$newgroup,$groups) { - global $ERROR_MSG; - if(!check_right("Host","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host, &$arr)) { - $ERROR_MSG="Hostname should contain 0-9a-zA-Z_.- characters only"; + error("Hostname should contain 0-9a-zA-Z_.- characters only"); return 0; } @@ -41,7 +39,7 @@ $result=DBexecute($sql); if(DBnum_rows($result)>0) { - $ERROR_MSG="Host '$host' already exists"; + error("Host '$host' already exists"); return 0; } @@ -83,17 +81,15 @@ function update_host($hostid,$host,$port,$status,$useip,$ip,$newgroup,$groups) { - global $ERROR_MSG; - if(!check_right("Host","U",$hostid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host, &$arr)) { - $ERROR_MSG="Hostname should contain 0-9a-zA-Z_.- characters only"; + error("Hostname should contain 0-9a-zA-Z_.- characters only"); return 0; } @@ -101,7 +97,7 @@ $result=DBexecute($sql); if(DBnum_rows($result)>0) { - $ERROR_MSG="Host '$host' already exists"; + error("Host '$host' already exists"); return 0; } @@ -178,8 +174,6 @@ function delete_host_group($groupid) { - global $ERROR_MSG; - $sql="delete from hosts_groups where groupid=$groupid"; DBexecute($sql); $sql="delete from groups where groupid=$groupid"; @@ -188,8 +182,6 @@ function get_host_by_hostid($hostid) { - global $ERROR_MSG; - $sql="select hostid,host,useip,ip,port,status from hosts where hostid=$hostid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -203,7 +195,7 @@ } else { - $ERROR_MSG="No host with hostid=[$hostid]"; + error("No host with hostid=[$hostid]"); } return $host; } diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index cc0e73c5..56e4a3f0 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -23,11 +23,9 @@ function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) { - global $ERROR_MSG; - if(!check_right("Item","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -35,19 +33,19 @@ $result=DBexecute($sql); if(DBget_field($result,0,0)>0) { - $ERROR_MSG="An item with the same Key already exists for this host. The key must be unique."; + error("An item with the same Key already exists for this host. The key must be unique."); return 0; } if($delay<1) { - $ERROR_MSG="Delay cannot be less than 1 second"; + error("Delay cannot be less than 1 second"); return 0; } if( ($snmp_port<1)||($snmp_port>65535)) { - $ERROR_MSG="Invalid SNMP port"; + error("Invalid SNMP port"); return 0; } @@ -71,11 +69,9 @@ function update_item_status($itemid,$status) { - global $ERROR_MSG; - if(!check_right("Item","U",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } if($status==ITEM_STATUS_ACTIVE) @@ -90,22 +86,20 @@ function update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends) { - global $ERROR_MSG; - if(!check_right("Item","U",$itemid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } if($delay<1) { - $ERROR_MSG="Delay cannot be less than 1 second"; + error("Delay cannot be less than 1 second"); return 0; } if( ($snmp_port<1)||($snmp_port>65535)) { - $ERROR_MSG="Invalid SNMP port"; + error("Invalid SNMP port"); return 0; } @@ -218,8 +212,6 @@ function get_item_by_itemid($itemid) { - global $ERROR_MSG; - $sql="select * from items where itemid=$itemid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -228,7 +220,7 @@ } else { - $ERROR_MSG="No item with itemid=[$itemid]"; + error("No item with itemid=[$itemid]"); } return $item; } diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php index 563d065a..0b0a758a 100644 --- a/frontends/php/include/maps.inc.php +++ b/frontends/php/include/maps.inc.php @@ -21,8 +21,6 @@ <?php function get_map_by_sysmapid($sysmapid) { - global $ERROR_MSG; - $sql="select * from sysmaps where sysmapid=$sysmapid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -31,7 +29,7 @@ } else { - $ERROR_MSG="No system map with sysmapid=[$sysmapid]"; + error("No system map with sysmapid=[$sysmapid]"); } return $result; } @@ -60,11 +58,9 @@ function update_sysmap($sysmapid,$name,$width,$height,$background,$label_type) { - global $ERROR_MSG; - if(!check_right("Network map","U",$sysmapid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -76,11 +72,9 @@ function add_sysmap($name,$width,$height,$background,$label_type) { - global $ERROR_MSG; - if(!check_right("Network map","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index 14a12d02..688e950b 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -21,11 +21,9 @@ <?php function add_screen($name,$cols,$rows) { - global $ERROR_MSG; - if(!check_right("Screen","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -35,11 +33,9 @@ function update_screen($screenid,$name,$cols,$rows) { - global $ERROR_MSG; - if(!check_right("Screen","U",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -81,8 +77,6 @@ function get_screen_by_screenid($screenid) { - global $ERROR_MSG; - $sql="select * from screens where screenid=$screenid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -91,7 +85,7 @@ } else { - $ERROR_MSG="No screen with screenid=[$screenid]"; + error("No screen with screenid=[$screenid]"); } return $result; } diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php index 786f1e3b..9c9af979 100644 --- a/frontends/php/include/services.inc.php +++ b/frontends/php/include/services.inc.php @@ -178,8 +178,6 @@ function add_service_link($servicedownid,$serviceupid,$softlink) { - global $ERROR_MSG; - if( ($softlink==0) && (is_service_hardlinked($servicedownid)==TRUE) ) { return FALSE; @@ -187,7 +185,7 @@ if($servicedownid==$serviceupid) { - $ERROR_MSG="Cannot link service to itself."; + error("Cannot link service to itself."); return FALSE; } @@ -325,8 +323,6 @@ function get_num_of_service_childs($serviceid) { - global $ERROR_MSG; - $sql="select count(*) from services_links where serviceupid=$serviceid"; $result=DBselect($sql); return DBget_field($result,0,0); @@ -334,8 +330,6 @@ function get_service_by_serviceid($serviceid) { - global $ERROR_MSG; - $sql="select * from services where serviceid=$serviceid"; $result=DBselect($sql); if(Dbnum_rows($result) == 1) @@ -344,7 +338,7 @@ } else { - $ERROR_MSG="No service with serviceid=[$serviceid]"; + error("No service with serviceid=[$serviceid]"); } return FALSE; } diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 3b2884dc..032bbe41 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -21,11 +21,9 @@ <?php function update_trigger_comments($triggerid,$comments) { - global $ERROR_MSG; - if(!check_right("Trigger comment","U",$triggerid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -38,11 +36,9 @@ function update_trigger_status($triggerid,$status) { - global $ERROR_MSG; - if(!check_right_on_trigger("U",$triggerid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } add_alarm($triggerid,2); @@ -103,11 +99,9 @@ function add_trigger($expression,$description,$priority,$status,$comments,$url) { - global $ERROR_MSG; - // if(!check_right("Trigger","A",0)) // { -// $ERROR_MSG="Insufficient permissions"; +// error("Insufficient permissions"); // return 0; // } @@ -136,13 +130,11 @@ function delete_trigger($triggerid) { - global $ERROR_MSG; - $sql="select count(*) from trigger_depends where triggerid_down=$triggerid or triggerid_up=$triggerid"; $result=DBexecute($sql); if(DBget_field($result,0,0)>0) { - $ERROR_MSG="Delete dependencies first"; + error("Delete dependencies first"); return FALSE; } @@ -178,11 +170,9 @@ function update_trigger($triggerid,$expression,$description,$priority,$status,$comments,$url) { - global $ERROR_MSG; - if(!check_right_on_trigger("U",$triggerid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -218,8 +208,6 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; function get_trigger_by_triggerid($triggerid) { - global $ERROR_MSG; - $sql="select triggerid,expression,description,status,priority,lastchange,dep_level,comments,url,value from triggers where triggerid=$triggerid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -228,7 +216,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } else { - $ERROR_MSG="No trigger with triggerid=[$triggerid]"; + error("No trigger with triggerid=[$triggerid]"); } return $trigger; } diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php index 9551064e..a6495424 100644 --- a/frontends/php/include/users.inc.php +++ b/frontends/php/include/users.inc.php @@ -23,11 +23,9 @@ function add_user($name,$surname,$alias,$passwd,$url) { - global $ERROR_MSG; - if(!check_right("User","A",0)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -41,11 +39,9 @@ function update_user($userid,$name,$surname,$alias,$passwd, $url) { - global $ERROR_MSG; - if(!check_right("User","U",$userid)) { - $ERROR_MSG="Insufficient permissions"; + error("Insufficient permissions"); return 0; } @@ -71,8 +67,6 @@ function get_user_by_userid($userid) { - global $ERROR_MSG; - $sql="select * from users where userid=$userid"; $result=DBselect($sql); if(DBnum_rows($result) == 1) @@ -81,7 +75,7 @@ } else { - $ERROR_MSG="No user with itemid=[$userid]"; + error("No user with itemid=[$userid]"); } return $result; } |