summaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-03-17 08:09:48 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-03-17 08:09:48 +0000
commitc1a9577153939aad68d3fbdc86e5ca70afa71394 (patch)
treee4329dc551bec2bed7dea62be247e67a6a569b60 /frontends
parent183033d3e4f67f05bb0fd0bb8cd394cb829e5f4a (diff)
downloadzabbix-c1a9577153939aad68d3fbdc86e5ca70afa71394.tar.gz
zabbix-c1a9577153939aad68d3fbdc86e5ca70afa71394.tar.xz
zabbix-c1a9577153939aad68d3fbdc86e5ca70afa71394.zip
- added frontends/php/include/actions.inc.php (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1699 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends')
-rw-r--r--frontends/php/include/actions.inc.php101
-rw-r--r--frontends/php/include/config.inc.php34
2 files changed, 101 insertions, 34 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
new file mode 100644
index 00000000..17f332c8
--- /dev/null
+++ b/frontends/php/include/actions.inc.php
@@ -0,0 +1,101 @@
+<?php
+/*
+** Zabbix
+** Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ # Update Action
+
+ function update_action( $actionid, $triggerid, $userid, $good, $delay, $subject, $message, $scope, $severity, $recipient, $usrgrpid)
+ {
+ delete_action($actionid);
+ return add_action( $triggerid, $userid, $good, $delay, $subject, $message, $scope, $severity, $recipient, $usrgrpid);
+ }
+
+ # Add Action
+
+ 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";
+ return 0;
+ }
+
+ if($recipient == RECIPIENT_TYPE_USER)
+ {
+ $id = $userid;
+ }
+ else
+ {
+ $id = $usrgrpid;
+ }
+
+ 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 h.hostid=i.hostid and i.itemid=f.itemid and t.triggerid=$triggerid";
+// echo "$sql<br>";
+ $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)";
+// echo "$sql<br>";
+ 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);
+ }
+ }
+
+ # Delete Action by userid
+
+ function delete_actions_by_userid( $userid )
+ {
+ $sql="select actionid from actions where userid=$userid";
+ $result=DBexecute($sql);
+ for($i=0;$i<DBnum_rows($result);$i++)
+ {
+ $actionid=DBget_field($result,$i,0);
+ delete_alert_by_actionid($actionid);
+ }
+
+ $sql="delete from actions where userid=$userid";
+ return DBexecute($sql);
+ }
+
+ # Delete Action
+
+ function delete_action( $actionid )
+ {
+ $sql="delete from actions where actionid=$actionid";
+ $result=DBexecute($sql);
+
+ return delete_alert_by_actionid($actionid);
+ }
+?>
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 8b49352f..4254574a 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -1781,13 +1781,6 @@ echo "</head>";
return DBexecute($sql);
}
- # Update Action
-
- function update_action( $actionid, $triggerid, $userid, $good, $delay, $subject, $message, $scope, $severity, $recipient, $usrgrpid)
- {
- delete_action($actionid);
- return add_action( $triggerid, $userid, $good, $delay, $subject, $message, $scope, $severity, $recipient, $usrgrpid);
- }
# Delete System Map
@@ -1823,33 +1816,6 @@ echo "</head>";
return DBexecute($sql);
}
-
- # Delete Action by userid
-
- function delete_actions_by_userid( $userid )
- {
- $sql="select actionid from actions where userid=$userid";
- $result=DBexecute($sql);
- for($i=0;$i<DBnum_rows($result);$i++)
- {
- $actionid=DBget_field($result,$i,0);
- delete_alert_by_actionid($actionid);
- }
-
- $sql="delete from actions where userid=$userid";
- return DBexecute($sql);
- }
-
- # Delete Action
-
- function delete_action( $actionid )
- {
- $sql="delete from actions where actionid=$actionid";
- $result=DBexecute($sql);
-
- return delete_alert_by_actionid($actionid);
- }
-
# Delete from History
function delete_history_by_itemid( $itemid )