diff options
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/actions.inc.php | 51 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 11 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 83 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 1 |
4 files changed, 111 insertions, 35 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index fed442eb..7b6b4370 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -62,13 +62,13 @@ # Add Action - function add_action( $filter_triggerid, $userid, $good, $delay, $subject, $message, $scope, $severity, $recipient, $usrgrpid, $maxrepeats, $repeatdelay) + function add_action( $userid, $good, $delay, $subject, $message, $recipient, $usrgrpid, $maxrepeats, $repeatdelay) { - if(!check_right_on_trigger("A",$triggerid)) - { - error("Insufficient permissions"); - return 0; - } +// if(!check_right_on_trigger("A",$triggerid)) +// { +// error("Insufficient permissions"); +// return 0; +// } if($recipient == RECIPIENT_TYPE_USER) { @@ -79,7 +79,7 @@ $id = $usrgrpid; } - $sql="insert into actions (tilter_triggerid,userid,good,delay,nextcheck,subject,message,severity,recipient,maxrepeats,repeatdelay) values ($filter_triggerid,$id,$good,$delay,0,'$subject','$message',$severity,$recipient,$maxrepeats,$repeatdelay)"; + $sql="insert into actions (userid,good,delay,nextcheck,subject,message,recipient,maxrepeats,repeatdelay) values ($id,$good,$delay,0,'$subject','$message',$recipient,$maxrepeats,$repeatdelay)"; $result=DBexecute($sql); return DBinsert_id($result,"actions","actionid"); } @@ -264,4 +264,41 @@ } return $desc; } + + function get_condition_desc($conditiontype, $operator, $value) + { + if($operator == CONDITION_OPERATOR_EQUAL) + { + $op="="; + } + else if($operator == CONDITION_OPERATOR_NOT_EQUAL) + { + $op="<>"; + } + + $desc=S_UNKNOWN; + if($conditiontype==CONDITION_TYPE_GROUP) + { + $group=get_group_by_groupid($value); + if($group) $desc=S_HOST_GROUP." $op "."\"".$group["name"]."\""; + } + else if($conditiontype==CONDITION_TYPE_TRIGGER_NAME) + { + $desc=S_TRIGGER_DESCRIPTION." $op "."\"".$value."\""; + } + else + { + } + return $desc; + } + + # Add Action's condition + + function add_action_condition($actionid, $conditiontype, $operator, $value) + { + $value=addslashes($value); + $sql="insert into conditions (actionid,conditiontype,operator,value) values ($actionid,$conditiontype,$operator,'$value')"; + $result=DBexecute($sql); + return DBinsert_id($result,"conditions","conditionid"); + } ?> diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 1b8bf426..76fbdc72 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -42,6 +42,17 @@ define("AUDIT_RESOURCE_ESCALATION_RULE",9); define("AUDIT_RESOURCE_AUTOREGISTRATION",10); + define("CONDITION_TYPE_GROUP", 0); + define("CONDITION_TYPE_HOST", 1); + define("CONDITION_TYPE_TRIGGER", 2); + define("CONDITION_TYPE_TRIGGER_NAME", 3); + define("CONDITION_TYPE_TRIGGER_SEVERITY",4); + define("CONDITION_TYPE_TRIGGER_VALUE", 5); + define("CONDITION_TYPE_TIME_PERIOD", 6); + + define("CONDITION_OPERATOR_EQUAL", 0); + define("CONDITION_OPERATOR_NOT_EQUAL", 1); + define("HOST_STATUS_MONITORED", 0); define("HOST_STATUS_NOT_MONITORED", 1); // define("HOST_STATUS_UNREACHABLE", 2); diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index bb1e7d38..deb740b7 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1501,11 +1501,7 @@ $actionid=$action["actionid"]; $actiontype=$action["actiontype"]; - $filter_triggerid=$action["filter_triggerid"]; - $filter_groupid=$action["filter_groupid"]; - $filter_hostid=$action["filter_hostid"]; $source=$action["source"]; - $filter_trigger_name=$action["filter_trigger_name"]; $good=$action["good"]; $delay=$action["delay"]; // Otherwise symbols like ",' will not be shown @@ -1513,7 +1509,6 @@ $message=$action["message"]; $uid=$action["userid"]; $scope=@iif(isset($_REQUEST["scope"]),$_REQUEST["scope"],$action["scope"]); - $severity=$action["severity"]; $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]); $maxrepeats=$action["maxrepeats"]; $repeatdelay=$action["repeatdelay"]; @@ -1559,7 +1554,7 @@ } } - $filtertype=@iif(isset($_REQUEST["filtertype"]),$_REQUEST["filtertype"],0); + $conditiontype=@iif(isset($_REQUEST["conditiontype"]),$_REQUEST["conditiontype"],0); show_form_begin("actions.action"); @@ -1578,43 +1573,73 @@ echo "<OPTION VALUE=\"0\""; if($source==0) echo "SELECTED"; echo ">".S_TRIGGER; echo "</SELECT>"; - show_table2_v_delimiter($col++); + show_table2_v_delimiter($col); echo nbsp("Conditions"); show_table2_h_delimiter(); - echo "<input type=checkbox name=\"zzz\" \">"."Host: zabbix.com"; - echo "<br>"; - echo "<input type=checkbox name=\"zzz\" \">"."Trigger: Processor load is too high on zabbix.com"; - echo "<br>"; - echo "<input type=checkbox name=\"zzz\" \">"."Trigger description like: \"Processor load is too high\""; + for($i=1;$i<=1000;$i++) + { + if(isset($_REQUEST["conditiontype$i"])) + { + echo "<input type=checkbox name=\"conditionchecked$i\">".get_condition_desc($_REQUEST["conditiontype$i"],$_REQUEST["conditionop$i"],$_REQUEST["conditionvalue$i"]); + echo "<br>"; + } + } + + for($i=1;$i<=1000;$i++) + { + if(isset($_REQUEST["conditiontype$i"])) + { + echo "<input name=\"conditiontype$i\" type=\"hidden\" value=\"".$_REQUEST["conditiontype$i"]."\">"; + echo "<input name=\"conditionop$i\" type=\"hidden\" value=\"".$_REQUEST["conditionop$i"]."\">"; + echo "<input name=\"conditionvalue$i\" type=\"hidden\" value=\"".$_REQUEST["conditionvalue$i"]."\">"; + } + } + + show_table2_v_delimiter($col++); + echo nbsp(" "); + show_table2_h_delimiter(); + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete selected\">"; // show_table2_v_delimiter($col); // echo nbsp(" "."Condition"); // show_table2_h_delimiter(); - $h2="<select class=\"biginput\" name=\"filtertype\" onChange=\"submit()\">>"; - $h2=$h2.form_select("filtertype",0,S_HOST_GROUP); - $h2=$h2.form_select("filtertype",1,S_HOST); - $h2=$h2.form_select("filtertype",2,S_TRIGGER); - $h2=$h2.form_select("filtertype",3,S_TRIGGER_NAME); - $h2=$h2.form_select("filtertype",4,S_TRIGGER_SEVERITY); - $h2=$h2.form_select("filtertype",5,S_TRIGGER_VALUE); - $h2=$h2.form_select("filtertype",6,S_TIME_PERIOD); + $h2="<select class=\"biginput\" name=\"conditiontype\" onChange=\"submit()\">"; + $h2=$h2.form_select("conditiontype",0,S_HOST_GROUP); + $h2=$h2.form_select("conditiontype",1,S_HOST); + $h2=$h2.form_select("conditiontype",2,S_TRIGGER); + $h2=$h2.form_select("conditiontype",3,S_TRIGGER_NAME); + $h2=$h2.form_select("conditiontype",4,S_TRIGGER_SEVERITY); + $h2=$h2.form_select("conditiontype",5,S_TRIGGER_VALUE); + $h2=$h2.form_select("conditiontype",6,S_TIME_PERIOD); $h2=$h2."</SELECT>"; // echo $h2; - if($filtertype==0) + $h2=$h2."<select class=\"biginput\" name=\"operator\">"; + $h2=$h2.form_select("operator",0,"="); + $h2=$h2.form_select("operator",1,"<>"); + $h2=$h2.form_select("operator",2,"like"); + $h2=$h2.form_select("operator",3,"not like"); + $h2=$h2."</SELECT>"; +// echo $h2; + + + show_table2_v_delimiter($col); + echo nbsp(" Condition"); + show_table2_h_delimiter(); + + if($conditiontype == CONDITION_TYPE_GROUP) { - show_table2_v_delimiter($col); - echo nbsp(" Condition"); - show_table2_h_delimiter(); - $h2=$h2." <b>=</b> "."<select class=\"biginput\" name=\"filter_groupid\">"; - $h2=$h2.form_select("groupid",0,S_ALL_SMALL); + $h2=$h2."<select class=\"biginput\" name=\"value\">"; $result=DBselect("select groupid,name from groups order by name"); while($row=DBfetch($result)) { - $h2=$h2.form_select("filter_groupid",$row["groupid"],$row["name"]); + $h2=$h2.form_select("value",$row["groupid"],$row["name"]); } $h2=$h2."</SELECT>"; - echo $h2; + } + else if($conditiontype == CONDITION_TYPE_TRIGGER_NAME) + { + $h2=$h2."<input class=\"biginput\" name=\"value\" value=\"\" size=40>"; } else { @@ -1730,6 +1755,8 @@ echo "<OPTION VALUE=\"2\""; if($good==2) echo "SELECTED"; echo ">".S_ON_OR_OFF; echo "</SELECT>"; } + echo $h2; + show_table2_v_delimiter($col++); echo nbsp(" "); show_table2_h_delimiter(); diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 0caaa2e9..8ec6c13f 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -61,6 +61,7 @@ "S_TRIGGER_SEVERITY"=> "Trigger severity", "S_TRIGGER_VALUE"=> "Trigger value", "S_TIME_PERIOD"=> "Time period", + "S_TRIGGER_DESCRIPTION"=> "Trigger description", // actions.php "S_ACTIONS"=> "Actions", |
