summaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'frontends')
-rw-r--r--frontends/php/hosts.php63
-rw-r--r--frontends/php/include/config.inc.php21
-rw-r--r--frontends/php/include/forms.inc.php37
-rw-r--r--frontends/php/include/local_en.inc.php6
4 files changed, 106 insertions, 21 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 99168122..829c20ad 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -39,6 +39,62 @@
<?php
if(isset($_GET["register"]))
{
+ if($_GET["register"]=="add linkage")
+ {
+ $items=0;
+ if(isset($_GET["items_add"])) $items=$items|1;
+ if(isset($_GET["items_update"])) $items=$items|2;
+ if(isset($_GET["items_delete"])) $items=$items|4;
+ $triggers=0;
+ if(isset($_GET["triggers_add"])) $triggers=$triggers|1;
+ if(isset($_GET["triggers_update"])) $triggers=$triggers|2;
+ if(isset($_GET["triggers_delete"])) $triggers=$triggers|4;
+ $actions=0;
+ if(isset($_GET["actions_add"])) $actions=$actions|1;
+ if(isset($_GET["actions_update"])) $actions=$actions|2;
+ if(isset($_GET["actions_delete"])) $actions=$actions|4;
+ $graphs=0;
+ if(isset($_GET["graphs_add"])) $graphs=$graphs|1;
+ if(isset($_GET["graphs_update"])) $graphs=$graphs|2;
+ if(isset($_GET["graphs_delete"])) $graphs=$graphs|4;
+ $screens=0;
+ if(isset($_GET["screens_add"])) $screens=$screens|1;
+ if(isset($_GET["screens_update"])) $screens=$screens|2;
+ if(isset($_GET["screens_delete"])) $screens=$screens|4;
+ $result=add_template_linkage($_GET["hostid"],$_GET["templateid"],$items,$triggers,$actions,$graphs,$screens);
+ show_messages($result, S_TEMPLATE_LINKAGE_ADDED, S_CANNOT_ADD_TEMPLATE_LINKAGE);
+ }
+ if($_GET["register"]=="update linkage")
+ {
+ $items=0;
+ if(isset($_GET["items_add"])) $items=$items|1;
+ if(isset($_GET["items_update"])) $items=$items|2;
+ if(isset($_GET["items_delete"])) $items=$items|4;
+ $triggers=0;
+ if(isset($_GET["triggers_add"])) $triggers=$triggers|1;
+ if(isset($_GET["triggers_update"])) $triggers=$triggers|2;
+ if(isset($_GET["triggers_delete"])) $triggers=$triggers|4;
+ $actions=0;
+ if(isset($_GET["actions_add"])) $actions=$actions|1;
+ if(isset($_GET["actions_update"])) $actions=$actions|2;
+ if(isset($_GET["actions_delete"])) $actions=$actions|4;
+ $graphs=0;
+ if(isset($_GET["graphs_add"])) $graphs=$graphs|1;
+ if(isset($_GET["graphs_update"])) $graphs=$graphs|2;
+ if(isset($_GET["graphs_delete"])) $graphs=$graphs|4;
+ $screens=0;
+ if(isset($_GET["screens_add"])) $screens=$screens|1;
+ if(isset($_GET["screens_update"])) $screens=$screens|2;
+ if(isset($_GET["screens_delete"])) $screens=$screens|4;
+ $result=update_template_linkage($_GET["hosttemplateid"],$_GET["hostid"],$_GET["templateid"],$items,$triggers,$actions,$graphs,$screens);
+ show_messages($result, S_TEMPLATE_LINKAGE_UPDATED, S_CANNOT_UPDATE_TEMPLATE_LINKAGE);
+ }
+ if($_GET["register"]=="delete linkage")
+ {
+ $result=delete_template_linkage($_GET["hosttemplateid"]);
+ show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE);
+ unset($_GET["hosttemplateid"]);
+ }
if($_GET["register"]=="add")
{
$groups=array();
@@ -158,6 +214,7 @@
$h2=S_GROUP."&nbsp;";
$h2=$h2."<input class=\"biginput\" name=\"config\" type=\"hidden\" value=\"".$_GET["config"]."\">";
+ $h2=$h2."<input class=\"biginput\" name=\"hostid\" type=\"hidden\" value=\"".$_GET["hostid"]."\">";
$h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
$h2=$h2."<option value=\"0\" ".iif(!isset($_GET["groupid"]),"selected","").">".S_ALL_SMALL;
@@ -268,7 +325,7 @@
table_begin();
table_header(array(S_HOST,S_TEMPLATE,S_ITEMS,S_TRIGGERS,S_ACTIONS,S_GRAPHS,S_SCREENS,S_ACTIONS));
- $result=DBselect("select hostid,templateid,items,triggers,actions,graphs,screens from hosts_templates where hostid=".$_GET["hostid"]);
+ $result=DBselect("select hosttemplateid,hostid,templateid,items,triggers,actions,graphs,screens from hosts_templates where hostid=".$_GET["hostid"]);
$col=0;
while($row=DBfetch($result))
{
@@ -276,7 +333,7 @@
$template=get_host_by_hostid($row["templateid"]);
// $members=array("hide"=>1,"value"=>"");
# $actions="<A HREF=\"hosts.php?config=".$_GET["config"]."&groupid=".$row["groupid"]."#form\">".S_CHANGE."</A>";
- $actions="ZZZ";
+ $actions="<a href=\"hosts.php?config=2&hostid=".$row["hostid"]."&hosttemplateid=".$row["hosttemplateid"]."\">".S_CHANGE."</a>";
table_row(array(
$host["host"],
@@ -299,7 +356,7 @@
}
if(isset($_GET["hostid"])&&$_GET["config"]==2)
{
- insert_template_form($_GET["hosttemplateid"]);
+ insert_template_form($_GET["hostid"], $_GET["hosttemplateid"]);
}
?>
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 38519007..1060655f 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -2996,6 +2996,27 @@ echo "</head>";
return DBexecute($sql);
}
+ # Add host-template linkage
+ function add_template_linkage($hostid,$templateid,$items,$triggers,$actions,$graphs,$screens)
+ {
+ $sql="insert into hosts_templates (hostid,templateid,items,triggers,actions,graphs,screens) values ($hostid,$templateid,$items,$triggers,$actions,$graphs,$screens)";
+ return DBexecute($sql);
+ }
+
+ # Update host-template linkage
+ function update_template_linkage($hosttemplateid,$hostid,$templateid,$items,$triggers,$actions,$graphs,$screens)
+ {
+ $sql="update hosts_templates set hostid=$hostid,templateid=$templateid,items=$items,triggers=$triggers,actions=$actions,graphs=$graphs,screens=$screens where hosttemplateid=$hosttemplateid";
+ return DBexecute($sql);
+ }
+
+ # Delete host-template linkage
+ function delete_template_linkage($hosttemplateid)
+ {
+ $sql="delete from hosts_templates where hosttemplateid=$hosttemplateid";
+ return DBexecute($sql);
+ }
+
# Add Host to system map
function add_host_to_sysmap($sysmapid,$hostid,$label,$x,$y,$icon,$url,$icon_on)
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 0cfd1bd5..e4b85328 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -24,11 +24,11 @@
include_once "include/local_en.inc.php";
# Insert host template form
- function insert_template_form($hosttemplateid)
+ function insert_template_form($hostid, $hosttemplateid)
{
if(isset($hosttemplateid))
{
- $result=DBselect("select u.alias,u.name,u.surname,u.passwd,u.url from users u where u.userid=$userid");
+ $result=DBselect("select * from hosts_templates where hosttemplateid=$hosttemplateid");
$row=DBfetch($result);
@@ -61,6 +61,7 @@
show_table2_v_delimiter($col++);
echo "<form method=\"get\" action=\"hosts.php\">";
echo "<input class=\"biginput\" name=\"config\" type=\"hidden\" value=\"".$_GET["config"]."\" size=8>";
+ echo "<input class=\"biginput\" name=\"hostid\" type=\"hidden\" value=\"".$_GET["hostid"]."\" size=8>";
if(isset($hosttemplateid))
{
echo "<input class=\"biginput\" name=\"hosttemplateid\" type=\"hidden\" value=\"$hosttemplateid\" size=8>";
@@ -90,41 +91,41 @@
show_table2_v_delimiter($col++);
echo S_ITEMS;
show_table2_h_delimiter();
- echo "<input type=checkbox checked name=\"items_add\" \">".S_ADD;
- echo "<input type=checkbox checked name=\"items_update\" \">".S_UPDATE;
- echo "<input type=checkbox checked name=\"items_delete\" \">".S_DELETE;
+ echo "<input type=checkbox ".iif((1&$items)==1,"checked","")." name=\"items_add\" \">".S_ADD;
+ echo "<input type=checkbox ".iif((2&$items)==2,"checked","")." name=\"items_update\" \">".S_UPDATE;
+ echo "<input type=checkbox ".iif((4&$items)==4,"checked","")." name=\"items_delete\" \">".S_DELETE;
show_table2_v_delimiter($col++);
echo S_TRIGGERS;
show_table2_h_delimiter();
- echo "<input type=checkbox checked name=\"triggers_add\" \">".S_ADD;
- echo "<input type=checkbox checked name=\"triggers_update\" \">".S_UPDATE;
- echo "<input type=checkbox checked name=\"triggers_delete\" \">".S_DELETE;
+ echo "<input type=checkbox ".iif((1&$triggers)==1,"checked","")." name=\"triggers_add\" \">".S_ADD;
+ echo "<input type=checkbox ".iif((2&$triggers)==2,"checked","")." name=\"triggers_update\" \">".S_UPDATE;
+ echo "<input type=checkbox ".iif((4&$triggers)==4,"checked","")." name=\"triggers_delete\" \">".S_DELETE;
show_table2_v_delimiter($col++);
echo S_ACTIONS;
show_table2_h_delimiter();
- echo "<input type=checkbox checked name=\"actions_add\" \">".S_ADD;
- echo "<input type=checkbox checked name=\"actions_update\" \">".S_UPDATE;
- echo "<input type=checkbox checked name=\"actions_delete\" \">".S_DELETE;
+ echo "<input type=checkbox ".iif((1&$actions)==1,"checked","")." name=\"actions_add\" \">".S_ADD;
+ echo "<input type=checkbox ".iif((2&$actions)==2,"checked","")." name=\"actions_update\" \">".S_UPDATE;
+ echo "<input type=checkbox ".iif((4&$actions)==4,"checked","")." name=\"actions_delete\" \">".S_DELETE;
show_table2_v_delimiter($col++);
echo S_GRAPHS;
show_table2_h_delimiter();
- echo "<input type=checkbox checked name=\"graphs_add\" \">".S_ADD;
- echo "<input type=checkbox checked name=\"graphs_update\" \">".S_UPDATE;
- echo "<input type=checkbox checked name=\"graphs_delete\" \">".S_DELETE;
+ echo "<input type=checkbox ".iif((1&$graphs)==1,"checked","")." name=\"graphs_add\" \">".S_ADD;
+ echo "<input type=checkbox ".iif((2&$graphs)==2,"checked","")." name=\"graphs_update\" \">".S_UPDATE;
+ echo "<input type=checkbox ".iif((4&$graphs)==4,"checked","")." name=\"graphs_delete\" \">".S_DELETE;
show_table2_v_delimiter($col++);
echo S_SCREENS;
show_table2_h_delimiter();
- echo "<input type=checkbox checked name=\"screens_add\" \">".S_ADD;
- echo "<input type=checkbox checked name=\"screens_update\" \">".S_UPDATE;
- echo "<input type=checkbox checked name=\"screens_delete\" \">".S_DELETE;
+ echo "<input type=checkbox ".iif((1&$screens)==1,"checked","")." name=\"screens_add\" \">".S_ADD;
+ echo "<input type=checkbox ".iif((2&$screens)==2,"checked","")." name=\"screens_update\" \">".S_UPDATE;
+ echo "<input type=checkbox ".iif((4&$screens)==4,"checked","")." name=\"screens_delete\" \">".S_DELETE;
show_table2_v_delimiter2($col++);
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add linkage\">";
- if(isset($userid))
+ if(isset($hosttemplateid))
{
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"update linkage\">";
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete linkage\" onClick=\"return Confirm('Delete selected linkage?');\">";
diff --git a/frontends/php/include/local_en.inc.php b/frontends/php/include/local_en.inc.php
index aaa05220..5b896fc0 100644
--- a/frontends/php/include/local_en.inc.php
+++ b/frontends/php/include/local_en.inc.php
@@ -240,6 +240,12 @@
define("S_CANNOT_UPDATE_HOST_STATUS", "Cannot update host status");
define("S_HOST_DELETED", "Host deleted");
define("S_CANNOT_DELETE_HOST", "Cannot delete host");
+ define("S_TEMPLATE_LINKAGE_ADDED", "Template linkage added");
+ define("S_CANNOT_ADD_TEMPLATE_LINKAGE", "Cannot add template linkage");
+ define("S_TEMPLATE_LINKAGE_UPDATED", "Template linkage updated");
+ define("S_CANNOT_UPDATE_TEMPLATE_LINKAGE", "Cannot update template linkage");
+ define("S_TEMPLATE_LINKAGE_DELETED", "Template linkage deleted");
+ define("S_CANNOT_DELETE_TEMPLATE_LINKAGE", "Cannot delete template linkage");
define("S_CONFIGURATION_OF_HOSTS_AND_HOST_GROUPS","CONFIGURATION OF HOSTS AND HOST GROUPS");
define("S_HOST_GROUPS_BIG", "HOST GROUPS");
define("S_NO_HOST_GROUPS_DEFINED", "No host groups defined");