summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/graphs.inc.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-07-18 13:20:33 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-07-18 13:20:33 +0000
commitdef2e0a7def21050b352556ceb7c31cea4ebbb1c (patch)
tree16e811bda782fde81debd4199f2015fcdb103836 /frontends/php/include/graphs.inc.php
parent125d97877ec6846cd8be946eb786621e3debec81 (diff)
downloadzabbix-def2e0a7def21050b352556ceb7c31cea4ebbb1c.tar.gz
zabbix-def2e0a7def21050b352556ceb7c31cea4ebbb1c.tar.xz
zabbix-def2e0a7def21050b352556ceb7c31cea4ebbb1c.zip
- developed template unlinking feature (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3057 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/graphs.inc.php')
-rw-r--r--frontends/php/include/graphs.inc.php48
1 files changed, 37 insertions, 11 deletions
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index 5c0f09fa..6f5c00f6 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -439,32 +439,58 @@
return $result;
}
- function delete_template_graphs_by_hostid($hostid)
+ function delete_template_graphs($hostid, $templateid = null, $unlink_mode = false)
{
$db_graphs = get_graphs_by_hostid($hostid);
while($db_graph = DBfetch($db_graphs))
{
- if($db_graph["templateid"] == 0) continue;
- delete_graph($db_graph["graphid"]);
+ if($db_graph["templateid"] == 0)
+ continue;
+
+ if($templateid != null)
+ {
+ $tmp_graph = get_graph_by_graphid($db_graph["templateid"]);
+ if($tmp_graph["hostid"] != $templateid)
+ continue;
+ }
+
+ if($unlink_mode)
+ {
+ if(DBexecute("update graphs set templateid=0 where graphid=".$db_graph["graphid"]))
+ {
+ info("Graph '".$db_graph["name"]."' unlinked");
+ }
+ }
+ else
+ {
+ delete_graph($db_graph["graphid"]);
+ }
}
}
- function sync_graphs_with_templates($hostid)
+ function copy_template_graphs($hostid, $templateid = null, $copy_mode = false)
{
- $host = get_host_by_hostid($hostid);
- $db_graphs = get_graphs_by_hostid($host["templateid"]);
+ if($templateid == null)
+ {
+ $host = get_host_by_hostid($hostid);
+ $templateid = $host["templateid"];
+ }
+
+ $db_graphs = get_graphs_by_hostid($templateid);
+
while($db_graph = DBfetch($db_graphs))
{
- copy_graph_to_host($db_graph["graphid"], $hostid);
+ copy_graph_to_host($db_graph["graphid"], $hostid, $copy_mode);
}
}
- function copy_graph_to_host($graphid, $hostid)
+ function copy_graph_to_host($graphid, $hostid, $copy_mode = false)
{
$db_graph = get_graph_by_graphid($graphid);
- $new_graphid = add_graph($db_graph["name"],$db_graph["width"],$db_graph["height"],
- $db_graph["yaxistype"],$db_graph["yaxismin"],$db_graph["yaxismax"],$db_graph["show_work_period"],
- $db_graph["show_triggers"],$graphid);
+ $new_graphid = add_graph($db_graph["name"],$db_graph["width"],$db_graph["height"],$db_graph["yaxistype"],
+ $db_graph["yaxismin"],$db_graph["yaxismax"],$db_graph["show_work_period"],$db_graph["show_triggers"],
+ $copy_mode ? 0 : $graphid
+ );
if(!$new_graphid)
return $new_graphid;