summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/graphs.inc.php
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-03-19 17:59:16 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-03-19 17:59:16 +0000
commit868a3852584b13e03c84442cb6dad32971f9b127 (patch)
tree9f6a614b918a0b4fda5ea6ca33a879faf4ace23d /frontends/php/include/graphs.inc.php
parent06039f6164b8ec63d2bb16dc55ff257ec6d5c896 (diff)
downloadzabbix-868a3852584b13e03c84442cb6dad32971f9b127.tar.gz
zabbix-868a3852584b13e03c84442cb6dad32971f9b127.tar.xz
zabbix-868a3852584b13e03c84442cb6dad32971f9b127.zip
- hard-linked templates works when adding graph element (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1717 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/graphs.inc.php')
-rw-r--r--frontends/php/include/graphs.inc.php40
1 files changed, 39 insertions, 1 deletions
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index 0c2da7dd..88c2476d 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -45,7 +45,8 @@
function add_item_to_graph($graphid,$itemid,$color,$drawtype,$sortorder)
{
$sql="insert into graphs_items (graphid,itemid,color,drawtype,sortorder) values ($graphid,$itemid,'$color',$drawtype,$sortorder)";
- return DBexecute($sql);
+ $result=DBexecute($sql);
+ return DBinsert_id($result,"graphs_items","gitemid");
}
# Update Graph
@@ -117,4 +118,41 @@
}
return $result;
}
+
+ function add_graph_item_to_templates($gitemid)
+ {
+ if($gitemid<=0)
+ {
+ return;
+ }
+
+ $graph_item=get_graphitem_by_gitemid($gitemid);
+ $graph=get_graph_by_graphid($graph_item["graphid"]);
+ $item=get_item_by_itemid($graph_item["itemid"]);
+
+ $sql="select hostid,templateid,actions from hosts_templates where templateid=".$item["hostid"];
+ $result=DBselect($sql);
+ while($row=DBfetch($result))
+ {
+ if($row["actions"]&1 == 0) continue;
+
+ $sql="select i.itemid from items i where i.key_='".$item["key_"]."' and i.hostid=".$row["hostid"];
+ $result2=DBselect($sql);
+ if(DBnum_rows($result2)==0) continue;
+ $row2=DBfetch($result2);
+ $itemid=$row2["itemid"];
+
+ $sql="select distinct g.graphid from graphs g,graphs_items gi,items i where i.itemid=gi.itemid and i.hostid=".$row["hostid"]." and g.graphid=gi.graphid and g.name='".addslashes($graph["name"])."'";
+ $result2=DBselect($sql);
+ while($row2=DBfetch($result2))
+ {
+ add_item_to_graph($row2["graphid"],$itemid,$graph_item["color"],$graph_item["drawtype"],$graph_item["sortorder"]);
+ }
+ if(DBnum_rows($result2)==0)
+ {
+ $graphid=add_graph($graph["name"],$graph["width"],$graph["height"],$graph["yaxistype"],$graph["yaxismin"],$graph["yaxismax"]);
+ add_item_to_graph($graphid,$itemid,$graph_item["color"],$graph_item["drawtype"],$graph_item["sortorder"]);
+ }
+ }
+ }
?>