summaryrefslogtreecommitdiffstats
path: root/frontends/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
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')
-rw-r--r--frontends/php/actionconf.php168
-rw-r--r--frontends/php/css.css9
-rw-r--r--frontends/php/hosts.php19
-rw-r--r--frontends/php/include/actions.inc.php20
-rw-r--r--frontends/php/include/classes/ccheckbox.inc.php9
-rw-r--r--frontends/php/include/classes/ccombobox.inc.php16
-rw-r--r--frontends/php/include/forms.inc.php198
-rw-r--r--frontends/php/media.php89
8 files changed, 271 insertions, 257 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)
diff --git a/frontends/php/css.css b/frontends/php/css.css
index 95335882..c456f061 100644
--- a/frontends/php/css.css
+++ b/frontends/php/css.css
@@ -269,6 +269,15 @@ tr.table_even_row:hover
{
color: #00AA00;
}
+A.enabled:link { color:#00AA00; text-decoration: none; }
+A.enabled:visited { color:#00AA00; text-decoration: none; }
+A.enabled:hover { color:#00AA00; text-decoration: underline; }
+A.enabled:active { color:#00AA00; text-decoration: underline;}
+
+A.disabled:link { color:#AA0000; text-decoration: none; }
+A.disabled:visited { color:#AA0000; text-decoration: none; }
+A.disabled:hover { color:#AA0000; text-decoration: underline; }
+A.disabled:active { color:#AA0000; text-decoration: underline;}
A.off:link { color:#00AA00; text-decoration: none; }
A.off:visited { color:#00AA00; text-decoration: none; }
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 292c28c9..48e7306f 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -317,13 +317,13 @@
$result=update_template_linkage($_REQUEST["hosttemplateid"],$_REQUEST["hostid"],$_REQUEST["templateid"],$items,$triggers,$graphs);
show_messages($result, S_TEMPLATE_LINKAGE_UPDATED, S_CANNOT_UPDATE_TEMPLATE_LINKAGE);
}
- if($_REQUEST["register"]=="delete linkage")
- {
- $result=delete_template_linkage($_REQUEST["hosttemplateid"]);
- show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE);
- unset($_REQUEST["hosttemplateid"]);
- }
}
+ if($_REQUEST["config"]==2&&isset($_REQUEST["delete"])&&isset($_REQUEST["hosttemplateid"]))
+ {
+ $result=delete_template_linkage($_REQUEST["hosttemplateid"]);
+ show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE);
+ unset($_REQUEST["hosttemplateid"]);
+ }
?>
@@ -419,7 +419,7 @@
if(isset($_REQUEST["hostid"]))
{
echo BR;
- @insert_template_form($_REQUEST["hostid"], $_REQUEST["hosttemplateid"]);
+ insert_template_form();
echo BR;
$table = new CTableInfo(S_NO_LINKAGES_DEFINED);
@@ -430,7 +430,6 @@
{
$host=get_host_by_hostid($row["hostid"]);
$template=get_host_by_hostid($row["templateid"]);
- $actions="<a href=\"hosts.php?config=2&hostid=".$row["hostid"]."&hosttemplateid=".$row["hosttemplateid"]."\">".S_CHANGE."</a>";
$table->addRow(array(
$host["host"],
@@ -438,7 +437,9 @@
get_template_permission_str($row["items"]),
get_template_permission_str($row["triggers"]),
get_template_permission_str($row["graphs"]),
- $actions
+ new CLink(S_CHANGE, "hosts.php?form=0".url_param("config").
+ "&hostid=".$row["hostid"].
+ "&hosttemplateid=".$row["hosttemplateid"])
));
}
$table->show();
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index e2180fce..621d9adc 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -36,7 +36,7 @@
# Add Action
- function add_action( $userid, $delay, $subject, $message, $recipient, $usrgrpid, $maxrepeats, $repeatdelay)
+ function add_action( $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay)
{
// if(!check_right_on_trigger("A",$triggerid))
// {
@@ -44,15 +44,6 @@
// return 0;
// }
- if($recipient == RECIPIENT_TYPE_USER)
- {
- $id = $userid;
- }
- else
- {
- $id = $usrgrpid;
- }
-
$sql="insert into actions (userid,delay,nextcheck,subject,message,recipient,maxrepeats,repeatdelay) values ($id,$delay,0,'$subject','$message',$recipient,$maxrepeats,$repeatdelay)";
$result=DBexecute($sql);
return DBinsert_id($result,"actions","actionid");
@@ -150,8 +141,13 @@
while($row2=DBfetch($result2))
{
$host=get_host_by_hostid($row["hostid"]);
- $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":", $action["message"]);
- add_action($row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["userid"], $action["maxrepeats"],$action["repeatdelay"]);
+ $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":",
+ $action["message"]);
+
+ add_action($row2["triggerid"], $action["userid"], $action["good"],
+ $action["delay"], $action["subject"], $message, $action["scope"],
+ $action["severity"], $action["recipient"], $action["maxrepeats"],
+ $action["repeatdelay"]);
}
}
}
diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php
index 36fe3962..01bd4d36 100644
--- a/frontends/php/include/classes/ccheckbox.inc.php
+++ b/frontends/php/include/classes/ccheckbox.inc.php
@@ -51,10 +51,15 @@
}
function SetChecked($value="yes")
{
- if($value=="yes" || $value=="checked" || $value=="on" || $value==1)
+ if(is_null($value)){
+ return 0;
+ }elseif((is_string($value)&&($value=="yes" || $value=="checked" || $value=="on"))
+ || (is_int($value)&&$value<>0)){
return $this->AddOption("checked","checked");
- elseif($value=="no" || $value=="unchecked" || $value=="off" || $value==NULL || $value==0)
+ }elseif((is_string($value)&&($value=="no" || $value=="unchecked" || $value=="off"))
+ || (is_int($value)&&$value==0)){
return $this->DelOption("checked");
+ }
return $this->error("Incorrect value for SetChacked [$value]");
}
function SetAction($value='submit()', $event='onClick')
diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php
index e05c8ea5..cecb45c3 100644
--- a/frontends/php/include/classes/ccombobox.inc.php
+++ b/frontends/php/include/classes/ccombobox.inc.php
@@ -46,17 +46,25 @@
}
function SetEnable($value='yes')
{
- if($value == 'yes' || $value == 'enabled' || $value=='on')
+ if(is_null($value))
+ return 0;
+ elseif((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on'))
+ || (is_int($value) && $value<>0))
return $this->DelOption('disabled');
- elseif($value == 'no' || $value == 'disabled' || $value=='off' || $value == NULL)
+ elseif((is_string($value) && ($value == 'no' || $value == 'disabled' || $value=='off'))
+ || (is_int($value) && $value==0))
return $this->AddOption('disabled','disabled');
return $this->error("Incorrect value for SetEnable [$value]");
}
function SetSelected($value='yes')
{
- if($value == 'yes' || $value == "selected" || $value=='on')
+ if(is_null($value))
+ return 0;
+ elseif((is_string($value) && ($value == 'yes' || $value == "selected" || $value=='on'))
+ || (is_int($value) && $value<>0))
return $this->AddOption('selected','selected');
- elseif($value == 'no' || $value=='off' || $value == NULL)
+ elseif((is_string($value) && ($value == 'no' || $value=='off'))
+ || (is_int($value) && $value==0))
return $this->DelOption('selected');
return $this->error("Incorrect value for SetSelected [$value]");
}
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index d598f447..dbd3cb57 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -24,41 +24,45 @@
// include_once "include/local_en.inc.php";
# Insert host template form
- function insert_template_form($hostid, $hosttemplateid)
+ function insert_template_form()
{
- if(isset($hosttemplateid))
+ global $_REQUEST;
+
+ $frmTemplate = new CFormTable(S_TEMPLATE,'hosts.php');
+ $frmTemplate->SetHelp('web.hosts.php');
+ $frmTemplate->AddVar('config',$_REQUEST["config"]);
+
+ if(isset($_REQUEST["hosttemplateid"])&&$_REQUEST["form"]!=1)
{
- $result=DBselect("select * from hosts_templates where hosttemplateid=$hosttemplateid");
+ $frmTemplate->AddVar('hosttemplateid',$_REQUEST["hosttemplateid"]);
+ $result=DBselect("select * from hosts_templates".
+ " where hosttemplateid=".$_REQUEST["hosttemplateid"]);
$row=DBfetch($result);
- $hostid=$row["hostid"];
- $host=get_host_by_hostid($hostid);
- $templateid=$row["templateid"];
- $template=get_host_by_hostid($templateid);
- $items=$row["items"];
- $triggers=$row["triggers"];
- $graphs=$row["graphs"];
+ $hostid = $row["hostid"];
+ $templateid = $row["templateid"];
+ $items = $row["items"];
+ $triggers = $row["triggers"];
+ $graphs = $row["graphs"];
}
else
{
- $hostid=0;
- $templateid=0;
- $items=7;
- $triggers=7;
- $graphs=7;
+ $hostid = get_request("hostid",0);
+ $templateid = get_request("templateid",0);
+ $items = get_request("items",7);
+ $triggers = get_request("triggers",7);
+ $graphs = get_request("graphs",7);
+ }
+ if($hostid!=0){
+ $host = get_host_by_hostid($hostid);
+ $frmTemplate->AddVar('hostid',$hostid);
}
-# create form
- $frmTemplate = new CFormTable(S_TEMPLATE,'hosts.php');
- $frmTemplate->SetHelp('web.hosts.php');
-# init vars
- $frmTemplate->AddVar('config',$_REQUEST["config"]);
- if($hostid!=0) $frmTemplate->AddVar('hostid',$hostid);
- if(isset($hosttemplateid)) $frmTemplate->AddVar('hosttemplateid',$_REQUEST["hosttemplateid"]);
-# init rows
- $cmbTemplate = new CComboBox('templateid',$templateid);
+ if($templateid!=0)
+ $template= get_host_by_hostid($templateid);
+ $cmbTemplate = new CComboBox('templateid',$templateid);
$hosts=DBselect("select hostid,host from hosts order by host");
while($host=DBfetch($hosts))
$cmbTemplate->AddItem($host["hostid"],$host["host"]);
@@ -84,13 +88,16 @@
));
$frmTemplate->AddItemToBottomRow(new CButton('register','add linkage'));
- if(isset($hosttemplateid))
+ if(isset($_REQUEST["hosttemplateid"]))
{
$frmTemplate->AddItemToBottomRow(SPACE);
$frmTemplate->AddItemToBottomRow(new CButton('register','update linkage'));
$frmTemplate->AddItemToBottomRow(SPACE);
- $frmTemplate->AddItemToBottomRow(new CButton('register','delete linkage',"return Confirm('Delete selected linkage?');"));
+ $frmTemplate->AddItemToBottomRow(new CButtonDelete('Delete selected linkage?',
+ url_param("config").url_param("hostid").url_param("hosttemplateid")));
}
+ $frmTemplate->AddItemToBottomRow(SPACE);
+ $frmTemplate->AddItemToBottomRow(new CButtonCancel(url_param("config").url_param("hostid")));
$frmTemplate->Show();
}
@@ -951,7 +958,7 @@
$frmAction = new CFormTable(S_ACTION,'actionconf.php');
$frmAction->SetHelp('web.actions.action');
- $conditiontype=@iif(isset($_REQUEST["conditiontype"]),$_REQUEST["conditiontype"],0);
+ $conditiontype = get_request("conditiontype",0);
if(isset($_REQUEST["actionid"]))
{
@@ -961,16 +968,16 @@
if(isset($_REQUEST["actionid"])&&$_REQUEST["form"]!=1)
{
- $actiontype=$action["actiontype"];
- $source=$action["source"];
- $delay=$action["delay"];
- $uid=$action["userid"];
- // Otherwise symbols like ",' will not be shown
- $subject=htmlspecialchars($action["subject"]);
- $message=$action["message"];
- $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]);
- $maxrepeats=$action["maxrepeats"];
- $repeatdelay=$action["repeatdelay"];
+ $actiontype = $action["actiontype"];
+ $source = $action["source"];
+ $delay = $action["delay"];
+ $uid = $action["userid"];
+ $subject = $action["subject"];
+ $message = $action["message"];
+ $recipient = $action["recipient"];
+ $maxrepeats = $action["maxrepeats"];
+ $repeatdelay = $action["repeatdelay"];
+
if(isset($_REQUEST["repeat"]))
{
$repeat=$_REQUEST["repeat"];
@@ -996,23 +1003,23 @@
}
else
{
- $source=get_request("source",0);
- $actiontype=get_request("actiontype",0);
+ $source = get_request("source",0);
+ $actiontype = get_request("actiontype",0);
- $delay=get_request("delay",30);
- $subject=get_request("subject","{TRIGGER.NAME}: {STATUS}");
- $message=get_request("message","{TRIGGER.NAME}: {STATUS}");
- $scope=get_request("scope",0);
- $recipient=get_request("recipient",RECIPIENT_TYPE_GROUP);
- $severity=get_request("severity",0);
- $maxrepeats=get_request("maxrepeats",0);
- $repeatdelay=get_request("repeatdelay",600);
- $repeat=get_request("repeat",0);
+ $delay = get_request("delay",30);
+ $subject = get_request("subject","{TRIGGER.NAME}: {STATUS}");
+ $message = get_request("message","{TRIGGER.NAME}: {STATUS}");
+ $scope = get_request("scope",0);
+ $recipient = get_request("recipient",RECIPIENT_TYPE_GROUP);
+ $severity = get_request("severity",0);
+ $maxrepeats = get_request("maxrepeats",0);
+ $repeatdelay = get_request("repeatdelay",600);
+ $repeat = get_request("repeat",0);
if($recipient==RECIPIENT_TYPE_GROUP)
- $uid=get_request("usrgrpid",NULL);
+ $uid = get_request("usrgrpid",NULL);
else
- $uid=get_request("userid",NULL);
+ $uid = get_request("userid",NULL);
}
@@ -1021,18 +1028,14 @@
for($i=1; $i<=1000; $i++)
{
if(!isset($_REQUEST["conditiontype$i"])) continue;
- array_push($cond_el,
- new CCheckBox(
- "conditionchecked$i",
- 'no',
+ array_push($cond_el, new CCheckBox(
+ "conditionchecked$i", 'no',
get_condition_desc(
$_REQUEST["conditiontype$i"],
$_REQUEST["conditionop$i"],
$_REQUEST["conditionvalue$i"]
- )
- ),
- BR
- );
+ )),BR
+ );
$frmAction->AddVar("conditiontype$i", $_REQUEST["conditiontype$i"]);
$frmAction->AddVar("conditionop$i", $_REQUEST["conditionop$i"]);
$frmAction->AddVar("conditionvalue$i", $_REQUEST["conditionvalue$i"]);
@@ -1110,24 +1113,24 @@
$txtCondVal = new CTextBox('host','',20);
$txtCondVal->SetReadonly('yes');
- $btnSelect = new CButton('btn1','Select',"window.open('popup.php?form=action&field1=value&field2=host','new_win','width=450,height=450,resizable=1,scrollbars=1');");
+ $btnSelect = new CButton('btn1','Select',
+ "window.open('popup.php?form=action&field1=value&field2=host',".
+ "'new_win','width=450,height=450,resizable=1,scrollbars=1');");
$btnSelect->SetAccessKey('T');
array_push($rowCondition, $txtCondVal, $btnSelect);
-// $cmbCondVal = new CComboBox('value');
-// $hosts = DBselect("select hostid,host from hosts order by host");
-// while($host = DBfetch($hosts))
-// {
-// $cmbCondVal->AddItem($host["hostid"],$host["host"]);
-// }
}
else if($conditiontype == CONDITION_TYPE_TRIGGER)
{
$cmbCondVal = new CComboBox('value');
- $triggers = DBselect("select distinct h.host,t.triggerid,t.description from triggers t, functions f,items i, hosts h where t.triggerid=f.triggerid and f.itemid=i.itemid and h.hostid=i.hostid order by h.host");
+ $triggers = DBselect("select distinct h.host,t.triggerid,t.description".
+ " from triggers t, functions f,items i, hosts h".
+ " where t.triggerid=f.triggerid and f.itemid=i.itemid".
+ " and h.hostid=i.hostid order by h.host");
while($trigger = DBfetch($triggers))
{
- $cmbCondVal->AddItem($trigger["triggerid"],$trigger["host"].":&nbsp;".$trigger["description"]);
+ $cmbCondVal->AddItem($trigger["triggerid"],
+ $trigger["host"].":&nbsp;".$trigger["description"]);
}
array_push($rowCondition,$cmbCondVal);
}
@@ -1218,16 +1221,17 @@
$frmAction->AddRow(S_DELAY_BETWEEN_REPEATS, new CTextBox('repeatdelay',$repeatdelay,2));
}
+ $frmAction->AddItemToBottomRow(new CButton('save',S_SAVE));
if(isset($_REQUEST["actionid"]))
{
- $frmAction->AddItemToBottomRow(new CButton('register','update'));
$frmAction->AddItemToBottomRow(SPACE);
- $frmAction->AddItemToBottomRow(new CButton('register','delete','return Confirm("Delete selected action?");'));
+ $frmAction->AddItemToBottomRow(new CButtonDelete("Delete selected action?",
+ url_param("actiontype").url_param("actionid")."&subject=".$subject));
+
} else {
- $frmAction->AddItemToBottomRow(new CButton('register','add'));
}
$frmAction->AddItemToBottomRow(SPACE);
- $frmAction->AddItemToBottomRow(new CButton('register','cancel'));
+ $frmAction->AddItemToBottomRow(new CButtonCancel(url_param("actiontype")));
$frmAction->Show();
}
@@ -1511,7 +1515,7 @@
$form->AddVar("resouceid",$resourceid);
}
- if($resource!=2)
+ if($resource!=3)
{
$form->AddRow(S_WIDTH, new CTextBox("width",$width,5));
$form->AddRow(S_HEIGHT, new CTextBox("height",$height,5));
@@ -1541,22 +1545,29 @@
{
global $_REQUEST;
- if(isset($_REQUEST["mediaid"]))
+ if(isset($_REQUEST["mediaid"]) && $_REQUEST["form"]!=1)
{
$media=get_media_by_mediaid($_REQUEST["mediaid"]);
- $severity=$media["severity"];
- $sendto=$media["sendto"];
- $active=$media["active"];
- $mediatypeid=$media["mediatypeid"];
- $period=$media["period"];
+
+ $severity = $media["severity"];
+ $sendto = $media["sendto"];
+ $mediatypeid = $media["mediatypeid"];
+ $active = $media["active"];
+ $period = $media["period"];
+
+ if($severity & 1) $_REQUEST["0"]='yes';
+ if($severity & 2) $_REQUEST["1"]='yes';
+ if($severity & 4) $_REQUEST["2"]='yes';
+ if($severity & 8) $_REQUEST["3"]='yes';
+ if($severity & 16) $_REQUEST["4"]='yes';
+ if($severity & 32) $_REQUEST["5"]='yes';
}
else
{
- $sendto="";
- $severity=63;
- $mediatypeid=-1;
- $active=0;
- $period="1-7,00:00-23:59";
+ $sendto = get_request("sendto","");
+ $mediatypeid = get_request("mediatypeid",0);
+ $active = get_request("active",0);
+ $period = get_request("period","1-7,00:00-23:59");
}
$frmMedia = new CFormTable(S_NEW_MEDIA,"media.php");
@@ -1569,8 +1580,7 @@
}
$cmbType = new CComboBox("mediatypeid",$mediatypeid);
- $sql="select mediatypeid,description from media_type order by type";
- $types=DBselect($sql);
+ $types=DBselect("select mediatypeid,description from media_type order by type");
while($type=DBfetch($types))
{
$cmbType->AddItem($type["mediatypeid"],$type["description"]);
@@ -1581,12 +1591,13 @@
$frmMedia->AddRow(S_WHEN_ACTIVE,new CTextBox("period",$period,48));
$frm_row = array();
- array_push($frm_row, new CCheckBox(0, 1 & $severity, S_NOT_CLASSIFIED), BR);
- array_push($frm_row, new CCheckBox(1, 2 & $severity, S_INFORMATION), BR);
- array_push($frm_row, new CCheckBox(2, 4 & $severity, S_WARNING), BR);
- array_push($frm_row, new CCheckBox(3, 8 & $severity, S_AVERAGE), BR);
- array_push($frm_row, new CCheckBox(4, 16 & $severity, S_HIGH), BR);
- array_push($frm_row, new CCheckBox(5, 32 & $severity, S_DISASTER), BR);
+
+ array_push($frm_row, new CCheckBox("0", get_request("0", 'no'), S_NOT_CLASSIFIED), BR);
+ array_push($frm_row, new CCheckBox("1", get_request("1", 'no'), S_INFORMATION), BR);
+ array_push($frm_row, new CCheckBox("2", get_request("2", 'no'), S_WARNING), BR);
+ array_push($frm_row, new CCheckBox("3", get_request("3", 'no'), S_AVERAGE), BR);
+ array_push($frm_row, new CCheckBox("4", get_request("4", 'no'), S_HIGH), BR);
+ array_push($frm_row, new CCheckBox("5", get_request("5", 'no'), S_DISASTER), BR);
$frmMedia->AddRow(S_USE_IF_SEVERITY,$frm_row);
$cmbStat = new CComboBox("active",$active);
@@ -1598,10 +1609,11 @@
if(isset($_REQUEST["mediaid"]))
{
$frmMedia->AddItemToBottomRow(SPACE);
- $frmMedia->AddItemToBottomRow(new CButton("delete",S_DELETE,"return Confirm('".S_DELETE_SELECTED_MEDIA_Q."');"));
+ $frmMedia->AddItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_MEDIA_Q,
+ url_param("userid").url_param("mediaid")));
}
$frmMedia->AddItemToBottomRow(SPACE);
- $frmMedia->AddItemToBottomRow(new CButton("cancel",S_CANCEL));
+ $frmMedia->AddItemToBottomRow(new CButtonCancel(url_param("userid")));
$frmMedia->Show();
}
diff --git a/frontends/php/media.php b/frontends/php/media.php
index f549e945..3997fba6 100644
--- a/frontends/php/media.php
+++ b/frontends/php/media.php
@@ -39,7 +39,7 @@
?>
<?php
- if(isset($_REQUEST["save"])&&isset($_REQUEST["mediaid"]))
+ if(isset($_REQUEST["save"]))
{
$severity=array();
if(isset($_REQUEST["0"])) $severity=array_merge($severity,array(0));
@@ -48,87 +48,90 @@
if(isset($_REQUEST["3"])) $severity=array_merge($severity,array(3));
if(isset($_REQUEST["4"])) $severity=array_merge($severity,array(4));
if(isset($_REQUEST["5"])) $severity=array_merge($severity,array(5));
- $result=update_media($_REQUEST["mediaid"], $_REQUEST["userid"], $_REQUEST["mediatypeid"], $_REQUEST["sendto"],$severity,$_REQUEST["active"],$_REQUEST["period"]);
- show_messages($result,S_MEDIA_UPDATED,S_CANNOT_UPDATE_MEDIA);
- }
- if(isset($_REQUEST["save"])&&!isset($_REQUEST["mediaid"]))
- {
- $severity=array();
- if(isset($_REQUEST["0"])) $severity=array_merge($severity,array(0));
- if(isset($_REQUEST["1"])) $severity=array_merge($severity,array(1));
- if(isset($_REQUEST["2"])) $severity=array_merge($severity,array(2));
- if(isset($_REQUEST["3"])) $severity=array_merge($severity,array(3));
- if(isset($_REQUEST["4"])) $severity=array_merge($severity,array(4));
- if(isset($_REQUEST["5"])) $severity=array_merge($severity,array(5));
- $result=add_media( $_REQUEST["userid"], $_REQUEST["mediatypeid"], $_REQUEST["sendto"],$severity,$_REQUEST["active"],$_REQUEST["period"]);
- show_messages($result, S_MEDIA_ADDED, S_CANNOT_ADD_MEDIA);
- }
+ if(isset($_REQUEST["mediaid"]))
+ {
+ $result=update_media($_REQUEST["mediaid"], $_REQUEST["userid"],
+ $_REQUEST["mediatypeid"], $_REQUEST["sendto"],$severity,
+ $_REQUEST["active"],$_REQUEST["period"]);
+
+ show_messages($result,S_MEDIA_UPDATED,S_CANNOT_UPDATE_MEDIA);
+ } else {
+ $result=add_media( $_REQUEST["userid"], $_REQUEST["mediatypeid"],
+ $_REQUEST["sendto"],$severity,$_REQUEST["active"],$_REQUEST["period"]);
- if(isset($_REQUEST["delete"]))
+ show_messages($result, S_MEDIA_ADDED, S_CANNOT_ADD_MEDIA);
+ }
+ if($result){
+ unset($_REQUEST["form"]);
+ }
+ }
+ elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["mediaid"]))
{
$result=delete_media( $_REQUEST["mediaid"] );
show_messages($result,S_MEDIA_DELETED, S_CANNOT_DELETE_MEDIA);
- unset($_REQUEST["mediaid"]);
}
-
- if(isset($_REQUEST["action"])&&($_REQUEST["action"]=="enable"))
+ elseif(isset($_REQUEST["enable"])&&isset($_REQUEST["mediaid"]))
{
- $result=activate_media( $_REQUEST["mediaid"] );
+ $result=activate_media($_REQUEST["mediaid"] );
show_messages($result, S_MEDIA_ACTIVATED, S_CANNOT_ACTIVATE_MEDIA);
}
-
-
- if(isset($_REQUEST["action"])&&($_REQUEST["action"]=="disable"))
+ elseif(isset($_REQUEST["disable"])&&isset($_REQUEST["mediaid"]))
{
$result=disactivate_media( $_REQUEST["mediaid"] );
show_messages($result, S_MEDIA_DISABLED, S_CANNOT_DISABLE_MEDIA);
}
?>
-
<?php
- $h1=S_MEDIA_BIG;
- $h2="<input class=\"button\" type=\"submit\" name=\"form\" value=\"".S_CREATE_MEDIA."\">";
- $h2=$h2."<input name=\"userid\" type=\"hidden\" value=".$_REQUEST["userid"].">";
- show_header2($h1, $h2, "<form name=\"selection\" method=\"get\" action=\"media.php\">", "</form>");
+ $form = new CForm("media.php");
+ $form->AddVar("userid",$_REQUEST["userid"]);
+ $form->AddItem(new CButton("form",S_CREATE_MEDIA));
+ show_header2(S_MEDIA_BIG, $form);
?>
-
<?php
- if(!isset($_REQUEST["form"]))
+ if(isset($_REQUEST["form"]))
+ {
+ echo BR;
+ insert_media_form();
+ }
+ else
{
- $sql="select m.mediaid,mt.description,m.sendto,m.active,m.period from media m,media_type mt where m.mediatypeid=mt.mediatypeid and m.userid=".$_REQUEST["userid"]." order by mt.type,m.sendto";
- $result=DBselect($sql);
-
$table = new CTableInfo(S_NO_MEDIA_DEFINED);
$table->setHeader(array(S_TYPE,S_SEND_TO,S_WHEN_ACTIVE,S_STATUS,S_ACTIONS));
- $col=0;
+ $result=DBselect("select m.mediaid,mt.description,m.sendto,m.active,m.period".
+ " from media m,media_type mt where m.mediatypeid=mt.mediatypeid".
+ " and m.userid=".$_REQUEST["userid"]." order by mt.type,m.sendto");
+
while($row=DBfetch($result))
{
if($row["active"]==0)
{
- $status="<a href=\"media.php?action=disable&mediaid=".$row["mediaid"]."&userid=".$_REQUEST["userid"]."\"><font color=\"00AA00\">".S_ENABLED."</font></A>";
+ $status=new CLink(S_ENABLED,
+ "media.php?disable=1&mediaid=".$row["mediaid"].url_param("userid"),
+ "enabled");
}
else
{
- $status="<a href=\"media.php?action=enable&mediaid=".$row["mediaid"]."&userid=".$_REQUEST["userid"]."\"><font color=\"AA0000\">".S_DISABLED."</font></A>";
+ $status=new CLink(S_DISABLED,
+ "media.php?enable=1&mediaid=".$row["mediaid"].url_param("userid"),
+ "disabled");
}
- $actions="<A HREF=\"media.php?register=change&form=0&mediaid=".$row["mediaid"]."&userid=".$_REQUEST["userid"]."\">".S_CHANGE."</A>";
+
$table->addRow(array(
$row["description"],
$row["sendto"],
$row["period"],
$status,
- $actions
+ new CLink(S_CHANGE,
+ "media.php?form=0&mediaid=".$row["mediaid"].
+ "&userid=".$_REQUEST["userid"]
+ )
));
}
$table->show();
}
- else
- {
- insert_media_form();
- }
?>
<?php