From e990ea261f1094378b664d754fdff4f839177a71 Mon Sep 17 00:00:00 2001 From: hugetoad Date: Thu, 17 Mar 2005 10:02:59 +0000 Subject: - hard-linked templates works when deleting an action (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@1706 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/actions.inc.php | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'frontends/php/include') diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 85849ab8..57d74467 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -138,4 +138,47 @@ } } } + + # Delete action from hardlinked hosts + + function delete_action_from_templates($actionid) + { + if($actionid<=0) + { + return; + } + + $action=get_action_by_actionid($actionid); + $trigger=get_trigger_by_triggerid($action["triggerid"]); + + $sql="select distinct h.hostid from hosts h,functions f, items i where i.itemid=f.itemid and h.hostid=i.hostid and f.triggerid=".$action["triggerid"]; + $result=DBselect($sql); + if(DBnum_rows($result)!=1) + { + return; + } + + $row=DBfetch($result); + + $hostid=$row["hostid"]; + + $sql="select hostid,templateid,actions from hosts_templates where templateid=$hostid"; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + if($row["actions"]&4 == 0) continue; + + $sql="select distinct f.triggerid from functions f,items i,triggers t where t.description='".addslashes($trigger["description"])."' and t.triggerid=f.triggerid and i.itemid=f.itemid and i.hostid=".$row["hostid"]; + $result2=DBselect($sql); + while($row2=DBfetch($result2)) + { + $sql="select actionid from actions where triggerid=".$row2["triggerid"]." and subject='".addslashes($action["subject"])."' and message='".addslashes($action["message"])."' and userid=".$action["userid"]." and good=".$action["good"]." and scope=".$action["scope"]." and recipient=".$action["recipient"]." and severity=".$action["severity"]; + $result3=DBselect($sql); + while($row3=DBfetch($result3)) + { + delete_action($row3["actionid"]); + } + } + } + } ?> -- cgit