diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-02-08 20:31:07 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2004-02-08 20:31:07 +0000 |
| commit | 5ad9a7a76d255d3cf47f8b678433efcbb9e57134 (patch) | |
| tree | 073a6a52fc03d8cb6ec5db17227a1cc87d14dd67 /frontends/php | |
| parent | 88e356bd3c51be5db7f7bafdc6b0acaedcc68182 (diff) | |
- changed DB schema. Dropped foreign key for table actions (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1247 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/actions.php | 10 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 23 |
2 files changed, 23 insertions, 10 deletions
diff --git a/frontends/php/actions.php b/frontends/php/actions.php index fbeafcdd..6bf1dd62 100644 --- a/frontends/php/actions.php +++ b/frontends/php/actions.php @@ -28,7 +28,7 @@ ?> <?php - if(!check_right_on_trigger("U",$HTTP_GET_VARS["triggerid"])) + if(($HTTP_GET_VARS["triggerid"]!=0)&&!check_right_on_trigger("U",$HTTP_GET_VARS["triggerid"])) { show_table_header("<font color=\"AA0000\">No permissions !</font>"); show_footer(); @@ -140,13 +140,7 @@ if($row["scope"] == 1) { -// $sql="select * from actions a,triggers t,hosts h,functions f,items i where a.triggerid=t.triggerid and f.triggerid=t.triggerid and i.itemid=f.itemid and h.hostid=i.hostid and t.triggerid=".$HTTP_GET_VARS["triggerid"]." and a.scope=1"; - $sql="select h.hostid from triggers t,hosts h,functions f,items i where f.triggerid=t.triggerid and i.itemid=f.itemid and h.hostid=i.hostid and t.triggerid=".$HTTP_GET_VARS["triggerid"]; -// echo $sql; - $result2=DBselect($sql); - if(DBnum_rows($result2)==0) continue; - $row2=DBfetch($result2); - $sql="select * from actions a,triggers t,hosts h,functions f,items i where a.triggerid=t.triggerid and f.triggerid=t.triggerid and i.itemid=f.itemid and h.hostid=i.hostid and t.triggerid=".$row["triggerid"]." and a.scope=1 and h.hostid=".$row2["hostid"]; + $sql="select * from actions a,triggers t,hosts h,functions f where a.triggerid=t.triggerid and f.triggerid=t.triggerid and h.hostid=a.triggerid and t.hostid=h.hostid and t.triggerid=".$HTTP_GET_VARS["triggerid"]."and a.scope=1 and h.hostid=".$row["triggerid"]; // echo $sql; $result2=DBselect($sql); if(DBnum_rows($result2)==0) continue; diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 52f47771..61a48afd 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1932,8 +1932,27 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $id = $usrgrpid; } - $sql="insert into actions (triggerid,userid,good,delay,nextcheck,subject,message,scope,severity,recipient) values ($triggerid,$id,$good,$delay,0,'$subject','$message',$scope,$severity,$recipient)"; - return DBexecute($sql); + if($scope==2) + { + $sql="insert into actions (triggerid,userid,good,delay,nextcheck,subject,message,scope,severity,recipient) values (0,$id,$good,$delay,0,'*Automatically generated*','*Automatically generated*',$scope,$severity,$recipient)"; + return DBexecute($sql); + } + elseif($scope==1) + { + $sql="select h.hostid from triggers t,hosts h,functions f,items i where f.triggerid=t.triggerid and t.hostid=h.hostid and h.hostid=i.itemid and i.itemid=f.itemid and t.triggerid=$triggerid"; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + $sql="insert into actions (triggerid,userid,good,delay,nextcheck,subject,message,scope,severity,recipient) values (".$row["hostid"].",$id,$good,$delay,0,'*Automatically generated*','*Automatically generated*',$scope,$severity,$recipient)"; + DBexecute($sql); + } + return TRUE; + } + else + { + $sql="insert into actions (triggerid,userid,good,delay,nextcheck,subject,message,scope,severity,recipient) values ($triggerid,$id,$good,$delay,0,'$subject','$message',$scope,$severity,$recipient)"; + return DBexecute($sql); + } } # Return TRUE if triggerid is a reason why the service is not OK |
