0) left join settings_tree on (graph_tree_items.id=settings_tree.graph_tree_item_id and settings_tree.user_id=$user_id) left join host on graph_tree_items.host_id=host.id $sql_join where graph_tree_items.graph_tree_id=$tree_id and graph_tree_items.order_key like '$search_key%' $sql_where order by graph_tree_items.order_key"); print "\n"; print "
"; print ""; $i = 0; /* loop through each tree item */ if (sizeof($heirarchy) > 0) { foreach ($heirarchy as $leaf) { /* find out how 'deep' this item is */ $tier = tree_tier($leaf["order_key"], 2); /* find the type of the current branch */ if ($leaf["title"] != "") { $current_leaf_type = "heading"; }elseif (!empty($leaf["local_graph_id"])) { $current_leaf_type = "graph"; }else{ $current_leaf_type = "host"; } /* find the type of the next branch. make sure the next item exists first */ if (isset($heirarchy{$i+1})) { if ($heirarchy{$i+1}["title"] != "") { $next_leaf_type = "heading"; }elseif (!empty($heirarchy{$i+1}["local_graph_id"])) { $next_leaf_type = "graph"; }else{ $next_leaf_type = "host"; } }else{ $next_leaf_type = ""; } if ((($current_leaf_type == 'heading') || ($current_leaf_type == 'host')) && (($tier <= $hide_until_tier) || ($hide_until_tier == false))) { $current_title = (($current_leaf_type == "heading") ? $leaf["title"] : $leaf["hostname"]); /* draw heading */ draw_tree_header_row($tree_id, $leaf["id"], $tier, $current_title, true, $leaf["status"], true); /* this is an open host, lets expand a bit */ if (($current_leaf_type == "host") && ($leaf["status"] == "0")) { /* get a list of all graph templates in use by this host */ $graph_templates = db_fetch_assoc("select graph_templates.id, graph_templates.name from graph_local,graph_templates,graph_templates_graph where graph_local.id=graph_templates_graph.local_graph_id and graph_templates_graph.graph_template_id=graph_templates.id and graph_local.host_id=" . $leaf["host_id"] . " group by graph_templates.id order by graph_templates.name"); if (sizeof($graph_templates) > 0) { foreach ($graph_templates as $graph_template) { draw_tree_header_row($tree_id, $leaf["id"], ($tier+1), $graph_template["name"], false, $leaf["status"], false); /* get a list of each graph using this graph template for this particular host */ $graphs = db_fetch_assoc("select graph_templates_graph.title_cache, graph_templates_graph.local_graph_id from graph_local,graph_templates,graph_templates_graph where graph_local.id=graph_templates_graph.local_graph_id and graph_templates_graph.graph_template_id=graph_templates.id and graph_local.graph_template_id=" . $graph_template["id"] . " and graph_local.host_id=" . $leaf["host_id"] . " order by graph_templates_graph.title_cache"); $graph_ct = 0; if (sizeof($graphs) > 0) { foreach ($graphs as $graph) { /* incriment graph counter so we know when to start a new row or not */ $graph_ct++; if (!isset($graphs[$graph_ct])) { $next_leaf_type = "heading"; }else{ $next_leaf_type = "graph"; } /* draw graph */ $already_open = draw_tree_graph_row($already_open, $graph_ct, $next_leaf_type, ($tier+2), $graph["local_graph_id"], 1, $graph["title_cache"]); } } } } } $graph_ct = 0; }elseif (($current_leaf_type == 'graph') && (($tier <= $hide_until_tier) || ($hide_until_tier == false))) { /* incriment graph counter so we know when to start a new row or not */ $graph_ct++; /* draw graph */ $already_open = draw_tree_graph_row($already_open, $graph_ct, $next_leaf_type, $tier, $leaf["local_graph_id"], $leaf["rra_id"], $leaf["graph_title"]); } /* if we have come back to the tier that was origionally flagged, then take away the flag */ if (($tier <= $hide_until_tier) && ($hide_until_tier != false)) { $hide_until_tier = false; } /* if we are supposed to hide this branch, flag it */ if (($leaf["status"] == "1") && ($hide_until_tier == false)) { $hide_until_tier = $tier; } $i++; } } print "
[root] - " . db_fetch_cell("select name from graph_tree where id=" . $_SESSION["sess_view_tree_id"]) . "
"; } function grow_edit_graph_tree($tree_id, $user_id, $options) { global $config, $colors; include_once($config["library_path"] . "/tree.php"); $tree = db_fetch_assoc("select graph_tree_items.id, graph_tree_items.title, graph_tree_items.local_graph_id, graph_tree_items.host_id, graph_tree_items.order_key, graph_templates_graph.title_cache as graph_title, CONCAT_WS('',description,' (',hostname,')') as hostname from graph_tree_items left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0) left join host on host.id=graph_tree_items.host_id where graph_tree_items.graph_tree_id=$tree_id order by graph_tree_items.order_key"); print "\n"; ## Here we go. Starting the main tree drawing loop. $i = 0; if (sizeof($tree) > 0) { foreach ($tree as $leaf) { $tier = tree_tier($leaf["order_key"], 2); $transparent_indent = " "; if ($i % 2 == 0) { $row_color = $colors["form_alternate1"]; }else{ $row_color = $colors["form_alternate2"]; } $i++; if ($leaf["local_graph_id"] > 0) { print "$transparent_indent" . $leaf["graph_title"] . "\n"; print "Graph"; }elseif ($leaf["title"] != "") { print "$transparent_indent" . $leaf["title"] . " (Add)\n"; print "Heading"; }elseif ($leaf["host_id"] > 0) { print "$transparent_indentHost: " . $leaf["hostname"] . "\n"; print "Host"; } print "\n Move Down\n Move Up\n \n"; print "\n Delete \n \n"; } }else{ print "No Graph Tree Items"; } } function grow_dropdown_tree($tree_id, $form_name, $selected_tree_item_id) { global $colors, $config; include_once($config["library_path"] . "/tree.php"); $tree = db_fetch_assoc("select graph_tree_items.id, graph_tree_items.title, graph_tree_items.order_key from graph_tree_items where graph_tree_items.graph_tree_id=$tree_id and graph_tree_items.title != '' order by graph_tree_items.order_key"); print "\n"; } function grow_dhtml_trees() { global $colors, $config; include_once($config["library_path"] . "/tree.php"); ?> Tree: $tree_name"; $title_delimeter = "-> "; } if (!empty($leaf_name)) { $title .= $title_delimeter . "Leaf: $leaf_name"; $title_delimeter = ", "; } if (!empty($host_name)) { $title .= $title_delimeter . "Host: $host_name"; $title_delimeter = ", "; } if (!empty($graph_template_name)) { $title .= $title_delimeter . "Graph Template: $graph_template_name"; $title_delimeter = "-> "; } print ""; print ""; if (empty($host_id)) { $heirarchy = db_fetch_assoc("select graph_tree_items.id, graph_tree_items.title, graph_tree_items.local_graph_id, graph_tree_items.rra_id, graph_tree_items.order_key, graph_templates_graph.title_cache as graph_title from graph_tree_items,graph_local left join graph_templates_graph on (graph_tree_items.local_graph_id=graph_templates_graph.local_graph_id and graph_tree_items.local_graph_id>0) $sql_join where graph_tree_items.graph_tree_id=$tree_id and graph_local.id=graph_templates_graph.local_graph_id and graph_tree_items.order_key like '$search_key" . "__" . str_repeat('0',60-(strlen($search_key)+2)) . "' and graph_tree_items.local_graph_id>0 $sql_where group by graph_tree_items.id order by graph_tree_items.order_key"); $i = 0; if (sizeof($heirarchy) > 0) { foreach ($heirarchy as $leaf) { form_alternate_row_color("f9f9f9", "ffffff", $i); print ""; print "\n"; $i++; } }else{ print ""; } }else{ $graph_templates = db_fetch_assoc("select graph_templates.id, graph_templates.name from graph_local,graph_templates,graph_templates_graph where graph_local.id=graph_templates_graph.local_graph_id and graph_templates_graph.graph_template_id=graph_templates.id and graph_local.host_id=$host_id " . (empty($graph_template_id) ? "" : "and graph_templates.id=$graph_template_id") . " group by graph_templates.id order by graph_templates.name"); /* for graphs without a template */ array_push($graph_templates, array( "id" => "0", "name" => "(No Graph Template)" )); if (sizeof($graph_templates) > 0) { foreach ($graph_templates as $graph_template) { $graphs = db_fetch_assoc("select graph_templates_graph.title_cache, graph_templates_graph.local_graph_id from graph_local,graph_templates_graph $sql_join where graph_local.id=graph_templates_graph.local_graph_id and graph_local.graph_template_id=" . $graph_template["id"] . " and graph_local.host_id=$host_id $sql_where order by graph_templates_graph.title_cache"); $i = 0; if (sizeof($graphs) > 0) { if (empty($graph_template_id)) { print ""; } foreach ($graphs as $graph) { form_alternate_row_color("f9f9f9", "ffffff", $i); print ""; print "\n"; $i++; } } } } } print "
$title
" . $leaf["graph_title"] . "
No graphs at this branch.
Graph Template: " . $graph_template["name"] . "
" . $graph["title_cache"] . "
"; } function find_first_folder_url() { $tree_list = get_graph_tree_array(); if (sizeof($tree_list) > 0) { $heirarchy = db_fetch_assoc("select graph_tree_items.id, graph_tree_items.host_id from graph_tree_items where graph_tree_items.graph_tree_id=" . $tree_list[0]["id"] . " and graph_tree_items.local_graph_id = 0 order by graph_tree_items.order_key"); if (sizeof($heirarchy) > 0) { return "graph_view.php?action=tree&tree_id=" . $tree_list[0]["id"] . "&leaf_id=" . $heirarchy[0]["id"] . "&select_first=true"; } } return; } function draw_tree_header_row($tree_id, $tree_item_id, $current_tier, $current_title, $use_expand_contract, $expand_contract_status, $show_url) { global $colors; /* start the nested table for the heading */ print "\n"; /* draw one vbar for each tier */ for ($j=0;($j<($current_tier-1));$j++) { print "\n"; } /* draw the '+' or '-' icons if configured to do so */ if (($use_expand_contract) && (!empty($current_title))) { if ($expand_contract_status == "1") { $other_status = '0'; $ec_icon = 'show'; }else{ $other_status = '1'; $ec_icon = 'hide'; } print "\n"; }elseif (!($use_expand_contract) && (!empty($current_title))) { print "\n"; } /* draw the actual cell containing the header */ if (!empty($current_title)) { print "\n"; } /* end the nested table for the heading */ print "
" . (($show_url == true) ? "" : "") . $current_title . (($show_url == true) ? "" : "") . " 
\n"; } function draw_tree_graph_row($already_open, $graph_counter, $next_leaf_type, $current_tier, $local_graph_id, $rra_id, $graph_title) { global $colors; /* start the nested table for the graph group */ if ($already_open == false) { print "\n"; /* draw one vbar for each tier */ for ($j=0;($j<($current_tier-1));$j++) { print "\n"; } print ""; print "
\n"; $already_open = true; } /* print out the actual graph html */ print "\n"; /* if we are at the end of a row, start a new one */ if ($graph_counter % read_graph_config_option("num_columns") == 0) { print "\n"; } /* if we are at the end of the graph group, end the nested table */ if ($next_leaf_type != "graph") { print "
$graph_title
\n"; $already_open = false; } return $already_open; } ?>