From 4e4aa7eb198963720b377cd568825309616dce8a Mon Sep 17 00:00:00 2001 From: artem Date: Mon, 16 Jul 2007 10:01:08 +0000 Subject: - added pie graphs (Artem) - added subclasses chart.inc.php and pie.inc.php, extending graph.inc.php (Artem) git-svn-id: svn://svn.zabbix.com/trunk@4458 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/graphs.inc.php | 147 +++++++++++++++++++---------------- 1 file changed, 78 insertions(+), 69 deletions(-) (limited to 'frontends/php/include/graphs.inc.php') diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index 85e9ac8e..8e561cd1 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -21,11 +21,17 @@ 0 && !DBfetch($graph_items)) @@ -446,7 +452,7 @@ * Comments: !!! Don't forget sync code with C !!! * * * ******************************************************************************/ - function delete_template_graphs($hostid, $templateid = null, $unlink_mode = false) + function delete_template_graphs($hostid, $templateid = null /* array format 'arr[id]=name' */, $unlink_mode = false) { $db_graphs = get_graphs_by_hostid($hostid); while($db_graph = DBfetch($db_graphs)) @@ -454,19 +460,22 @@ if($db_graph["templateid"] == 0) continue; - if( !is_null($templateid) ) + if($templateid != null) { - if( !is_array($templateid) ) $templateid=array($templateid); - - $tmp_host = DBfetch(get_hosts_by_graphid($db_graph["templateid"])); - - if( !in_array($tmp_host["hostid"], $templateid)) + $hosts = get_hosts_by_graphid($db_graph["templateid"]); + $tmp_host = DBfetch($hosts); + if(is_array($templateid)) + { + if(!isset($templateid[$tmp_host["hostid"]])) + continue; + } + elseif($tmp_host["hostid"] != $templateid) continue; } if($unlink_mode) { - if(DBexecute("update graphs set templateid=0 where graphid=".$db_graph["graphid"])) + if(DBexecute("update graphs set templateid=0 WHERE graphid=".$db_graph["graphid"])) { info("Graph '".$db_graph["name"]."' unlinked"); } @@ -483,16 +492,16 @@ * Comments: !!! Don't forget sync code with C !!! * * * ******************************************************************************/ - function copy_template_graphs($hostid, $templateid = null, $copy_mode = false) + function copy_template_graphs($hostid, $templateid = null /* array format 'arr[id]=name' */, $copy_mode = false) { if($templateid == null) { - $templateid = array_keys(get_templates_by_hostid($hostid)); + $templateid = get_templates_by_hostid($hostid); } if(is_array($templateid)) { - foreach($templateid as $id) + foreach($templateid as $id => $name) copy_template_graphs($hostid, $id, $copy_mode); // attention recursion return; } -- cgit