summaryrefslogtreecommitdiffstats
path: root/frontends/php/actionconf.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-01-26 16:08:54 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-01-26 16:08:54 +0000
commit2f3c1099996bca8c050b452852d52d91cb6be3f6 (patch)
tree5798dd1aa97193482203c9ecacb7e04a17979849 /frontends/php/actionconf.php
parent3d3f9639bc0524d6085d11041d70d23fbbda1c88 (diff)
downloadzabbix-2f3c1099996bca8c050b452852d52d91cb6be3f6.tar.gz
zabbix-2f3c1099996bca8c050b452852d52d91cb6be3f6.tar.xz
zabbix-2f3c1099996bca8c050b452852d52d91cb6be3f6.zip
- Frontend improvements (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2565 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/actionconf.php')
-rw-r--r--frontends/php/actionconf.php168
1 files changed, 74 insertions, 94 deletions
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php
index b0069e4e..0f4f1576 100644
--- a/frontends/php/actionconf.php
+++ b/frontends/php/actionconf.php
@@ -28,6 +28,8 @@
?>
<?php
+ $_REQUEST["actiontype"] = get_request("actiontype",0);
+
update_profile("web.menu.config.last",$page["file"]);
// if(($_REQUEST["triggerid"]!=0)&&!check_right_on_trigger("U",$_REQUEST["triggerid"]))
// {
@@ -38,103 +40,79 @@
?>
<?php
- if(isset($_REQUEST["register"]))
+ if(isset($_REQUEST["save"]))
{
- if($_REQUEST["register"]=="cancel")
+ if($_REQUEST["repeat"]==0)
{
- unset($_REQUEST["form"]);
+ $_REQUEST["maxrepeats"]=0;
+ $_REQUEST["repeatdelay"]=600;
}
- elseif($_REQUEST["register"]=="add")
- {
- if($_REQUEST["repeat"]==0)
- {
- $_REQUEST["maxrepeats"]=0;
- $_REQUEST["repeatdelay"]=600;
- }
- $actionid=add_action($_REQUEST["userid"], $_REQUEST["delay"], $_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"],$_REQUEST["usrgrpid"],$_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"]);
-// add_action_to_linked_hosts($actionid);
- for($i=1;$i<=1000;$i++)
- {
- if(isset($_REQUEST["conditiontype$i"]))
- {
- add_action_condition($actionid,$_REQUEST["conditiontype$i"], $_REQUEST["conditionop$i"], $_REQUEST["conditionvalue$i"]);
- }
- }
- show_messages($actionid,S_ACTION_ADDED,S_CANNOT_ADD_ACTION);
- if($actionid)
- {
- if(isset($_REQUEST["userid"]))
- {
- $user=get_user_by_userid($_REQUEST["userid"]);
- add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION,"User [".$user["alias"]."] subject [".$_REQUEST["subject"]."]");
- }
- else
- {
- $group=get_group_by_groupid($_REQUEST["usrgrpid"]);
- add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION,"User [".$group["name"]."] subject [".$_REQUEST["subject"]."]");
- }
- }
- unset($_REQUEST["form"]);
- }
- if($_REQUEST["register"]=="update")
- {
- if($_REQUEST["repeat"]==0)
- {
- $_REQUEST["maxrepeats"]=0;
- $_REQUEST["repeatdelay"]=600;
- }
+ if($_REQUEST['recipient'] == RECIPIENT_TYPE_USER)
+ $id = $_REQUEST['userid'];
+ else
+ $id = $_REQUEST['usrgrpid'];
+ if(isset($_REQUEST["actionid"])){
$actionid=$_REQUEST["actionid"];
+ $result = update_action($actionid, $id, $_REQUEST["delay"], $_REQUEST["subject"],
+ $_REQUEST["message"],$_REQUEST["recipient"],$_REQUEST["maxrepeats"],
+ $_REQUEST["repeatdelay"]);
- if($_REQUEST['recipient'] == RECIPIENT_TYPE_USER)
- {
- $id = $_REQUEST['userid'];
- }
- else
+ show_messages($result,S_ACTION_UPDATED,S_CANNOT_UPDATE_ACTION);
+ } else {
+ $actionid=add_action($id, $_REQUEST["delay"], $_REQUEST["subject"],
+ $_REQUEST["message"],$_REQUEST["recipient"],$_REQUEST["maxrepeats"],
+ $_REQUEST["repeatdelay"]);
+ $result=$actionid;
+
+ show_messages($result,S_ACTION_ADDED,S_CANNOT_ADD_ACTION);
+ }
+
+// add_action_to_linked_hosts($actionid);
+
+ if($result) // result - OK
+ {
+
+ DBexecute("delete from conditions where actionid=$actionid");
+ for($i=1;$i<=1000;$i++)
{
- $id = $_REQUEST['usrgrpid'];
+ if(!isset($_REQUEST["conditiontype$i"])) continue;
+ add_action_condition($actionid,$_REQUEST["conditiontype$i"],
+ $_REQUEST["conditionop$i"], $_REQUEST["conditionvalue$i"]);
}
-
- update_action($actionid, $id, $_REQUEST["delay"], $_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"],$_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"]);
- $sql="delete from conditions where actionid=$actionid";
- DBexecute($sql);
- for($i=1;$i<=1000;$i++)
+ if(isset($_REQUEST["userid"]))
{
- if(isset($_REQUEST["conditiontype$i"]))
- {
- add_action_condition($actionid,$_REQUEST["conditiontype$i"], $_REQUEST["conditionop$i"], $_REQUEST["conditionvalue$i"]);
- }
+ $user=get_user_by_userid($_REQUEST["userid"]);
+ add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION,
+ "User [".$user["alias"]."] subject [".$_REQUEST["subject"]."]");
}
- show_messages($actionid,S_ACTION_UPDATED,S_CANNOT_UPDATE_ACTION);
- if($actionid)
+ else
{
- if(isset($_REQUEST["userid"]))
- {
- $user=get_user_by_userid($_REQUEST["userid"]);
- add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ACTION,"User [".$user["alias"]."] subject [".$_REQUEST["subject"]."]");
- }
- else
- {
- $group=get_group_by_groupid($_REQUEST["usrgrpid"]);
- add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION,"User [".$group["name"]."] subject [".$_REQUEST["subject"]."]");
- }
+ $group=get_group_by_groupid($_REQUEST["usrgrpid"]);
+ add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ACTION,
+ "User [".$group["name"]."] subject [".$_REQUEST["subject"]."]");
}
unset($_REQUEST["form"]);
}
- if($_REQUEST["register"]=="delete")
- {
+ }
+ elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["actionid"]))
+ {
// delete_action_from_templates($_REQUEST["actionid"]);
- $result=delete_action($_REQUEST["actionid"]);
- show_messages($result,S_ACTION_DELETED,S_CANNOT_DELETE_ACTION);
- if($result)
- {
- add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_ACTION,"Subject [".$_REQUEST["subject"]."]");
- }
- unset($_REQUEST["actionid"]);
- unset($_REQUEST["form"]);
+
+ $result=delete_action($_REQUEST["actionid"]);
+ show_messages($result,S_ACTION_DELETED,S_CANNOT_DELETE_ACTION);
+ if($result)
+ {
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_ACTION,
+ "Subject [".$_REQUEST["subject"]."]");
}
+ unset($_REQUEST["actionid"]);
+ unset($_REQUEST["form"]);
+ }
+ elseif(isset($_REQUEST["register"]))
+ {
if($_REQUEST["register"]=="add condition")
{
for($i=1;$i<=1000;$i++)
@@ -149,7 +127,7 @@
$_REQUEST["conditiontype$num"]=$_REQUEST["conditiontype"];
$_REQUEST["conditionvalue$num"]=$_REQUEST["value"];
}
- if($_REQUEST["register"]=="delete selected")
+ elseif($_REQUEST["register"]=="delete selected")
{
for($i=1;$i<=1000;$i++)
{
@@ -171,21 +149,22 @@
}
else
{
- $h1=S_ACTIONS;
+ $form = new CForm("actionconf.php");
+
+ $cmbType = new CComboBox("actiontype",$_REQUEST["actiontype"],"submit()");
+ $cmbType->AddItem(0,S_SEND_MESSAGE);
+ $cmbType->AddItem(1,S_REMOTE_COMMAND,NULL,'no');
+ $form->AddItem($cmbType);
+
+ $form->AddItem("&nbsp;|&nbsp;");
+ $form->AddItem(new CButton("form",S_CREATE_ACTION));
-# $h2=S_GROUP."&nbsp;";
- $h2="";
- $h2=$h2."<select class=\"biginput\" name=\"actiontype\" onChange=\"submit()\">";
- $h2=$h2.form_select("actiontype",0,S_SEND_MESSAGE);
-// $h2=$h2.form_select("actiontype",1,S_REMOTE_COMMAND);
- $h2=$h2."</select>";
+ show_header2(S_ACTIONS, $form);
- $h2=$h2."&nbsp;|&nbsp;";
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"form\" value=\"".S_CREATE_ACTION."\">";
- show_header2($h1, $h2, "<form name=\"selection\" method=\"get\" action=\"actionconf.php\">", "</form>");
$tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED);
- $tblActions->SetHeader(array(S_SOURCE,S_CONDITIONS,S_SEND_MESSAGE_TO,S_DELAY,S_SUBJECT,S_REPEATS,S_ACTIONS));
+ $tblActions->SetHeader(array(S_SOURCE,S_CONDITIONS,S_SEND_MESSAGE_TO,
+ S_DELAY,S_SUBJECT,S_REPEATS,S_ACTIONS));
if(isset($_REQUEST["actiontype"])&&($_REQUEST["actiontype"]==1))
{
@@ -198,12 +177,13 @@
$result=DBselect($sql);
while($row=DBfetch($result))
{
- $sql="select * from conditions where actionid=".$row["actionid"]." order by conditiontype";
- $result2=DBselect($sql);
$conditions="";
+ $result2=DBselect("select * from conditions where actionid=".$row["actionid"].
+ " order by conditiontype");
while($condition=DBfetch($result2))
{
- $conditions=$conditions.get_condition_desc($condition["conditiontype"],$condition["operator"],$condition["value"])."<br>";
+ $conditions=$conditions.get_condition_desc($condition["conditiontype"],
+ $condition["operator"],$condition["value"]).BR;
}
if($row["recipient"] == RECIPIENT_TYPE_USER)