\n"; $treeinfo = db_fetch_row("SELECT * FROM graph_tree_view WHERE id = $args[tree_id]"); ## This code makes sure that the tree you're trying to show is either a public tree or owned by you. # if ($treeinfo[Owner] == '' || ($treeinfo[Owner] != 0 && $treeinfo[Owner] != $user_id)) { # print "

GRAPH TREE IS NOT PUBLIC AND DOESN'T BELONG TO YOU.
ACCESS DENIED!

\n"; # exit; # } # print "

$treeinfo[Title]

\n"; if ($config["global_auth"]["value"] == "on") { $sql = "select h.id,h.graph_id,h.rra_id,h.type,h.title,h.order_key, g.Title as gtitle, st.Status as status, ag.graphid as aggraphid, ag.userid as aguserid from graph_tree_view_items h left join rrd_graph g on h.graph_id=g.id left join settings_tree st on (h.id=st.treeitemid and st.userid=$user_id) left join auth_graph ag on (g.id=ag.graphid and ag.userid=$user_id) where h.tree_id=$tree_id and h.order_key like '$search_key%' $sql_where order by h.order_key"; }else{ $sql = "select h.id,h.graph_id,h.rra_id,h.type,h.title,h.order_key, g.title as gtitle, r.name as rname, st.Status as status from graph_tree_view_items h left join rrd_graph g on h.graph_id=g.id left join rrd_rra r on h.rraid=r.id left join settings_tree st on (h.id=st.treeitemid and st.userid=$user_id) where h.tree_id=$tree_id and h.order_key like '$search_key%' order by h.order_key"; } # print "$sql
\n"; $heirarchy = db_fetch_assoc($sql); $search_key = preg_replace("/0+$/","",$start_branch); ## First off, we walk the tree from the top to the root. We do it in that order so that we for ($i = (sizeof($heirarchy) - 1); $i > 0; --$i) { $leaf = $heirarchy[$i]; ## While we're walking the tree, let's go ahead and set 'hide' flags for any branches that should be hidden (status in settings_tree == 1) if ($set[status] == 1) { $hide[preg_replace("/0+$/","",$set[order_key])] = 1; # print "Adding Hide for '".preg_replace("/0+$/","",$set[order_key])."'
\n"; } $tier = tree_tier($leaf[order_key], 2); $parent_key = str_pad(substr($leaf[order_key],0,(($tier - 1) * 2) ),60,'0',STR_PAD_RIGHT); ## If there's a graph_id, the leaf is a graph, not a heading, so we increment the parent's num_graphs if ($leaf[graph_id]) { ++$num_graphs[$parent_key]; # print "graph_id = '$leaf[graph_id]'. Incrementing parent '$parent_key'.
\n"; } ## We also need the max_tier to do colspans so we do this to get it: if ($tier > $max_tier) { $max_tier = $tier; } } ## Now that we know how many graphs each heading has and whether it's supposed to be hidden, we walk the tree again from top to root to figure ## out how many rows each vertical bar should span. for ($i = (sizeof($heirarchy) - 1); $i >= 0; --$i) { $leaf = $heirarchy[$i]; $tier = tree_tier($leaf[order_key], 2); if (!$leaf[graph_id]) { # print "Checking header $leaf[id], $leaf[order_key], num_graphs = '".$num_graphs[$leaf[order_key]]."'
\n"; if (! $hide[preg_replace("/0+$/","",$leaf[order_key])]) { if ($num_graphs[$leaf[order_key]] > 0) { ++$rowspans[$leaf[order_key]]; # print "num_graphs[$leaf[order_key]] > 0 - incrementing rowspans[$leaf[order_key]]
\n"; } } $j = $tier - 1; $parent_key = str_pad(substr($leaf[order_key],0,$j * 2 ),60,'0',STR_PAD_RIGHT); $rowspans[$parent_key] += ($rowspans[$leaf[order_key]] + 1); # print "Adding ".($rowspans[$leaf[order_key]] + 1)." to rowspans[$parent_key] for $leaf[id]
\n"; } } $indent = " "; print "\n"; DrawMatrixTableBegin(); $already_open = false; ## Here we go. Starting the main tree drawing loop. if (sizeof($heirarchy) > 0) { foreach ($heirarchy as $leaf) { ## Need to remember what this block is for... :) $no_graphs = 0; if (sizeof($hide) > 0) { foreach (array_keys($hide) as $key_root) { if (preg_match("/^$key_root/",$leaf[order_key])) { if (preg_match("/^".$key_root."00/",$leaf[order_key])) { $no_graphs = 1; } else { $skip_entry = 1; } } } } if ($skip_entry) { $skip_entry = 0; continue; } $tier = tree_tier($leaf[order_key], 2); $current_leaf_type = $leaf[graph_id] ? "graph" : "heading"; if ($current_leaf_type == 'heading') { ## If this isn't the first heading, we may have to close tables/rows. if ($heading_ct > 0) { if ($need_table_close) { if ($graph_ct % 2 == 0) { print "\n"; } print "\n"; $already_open = false; } } $colspan = (($max_tier - $tier) * 2); $rowspan = $rowspans[$leaf[order_key]]; # print "Order key = '$leaf[order_key]', rs = '".$rowspans[$leaf[order_key]]."', rowspan = '$rowspan'
\n"; if (! $already_open) { print "\n"; $already_open = true; } if ($options[use_expand_contract]) { if ($hide[preg_replace("/0+$/","",$leaf[order_key])] == 1) { $other_status = '0'; $ec_icon = 'show'; } else { $other_status = '1'; $ec_icon = 'hide'; ++$heading_ct; } print "\n"; } else { print "$indent\n"; } print "$leaf[title]\n"; $already_open = false; ## If a heading isn't hidden and has graphs, start the vertical bar. if (! $hide[preg_replace("/0+$/","",$leaf[order_key])] && $rowspan > 0) { print " \n"; $already_open = true; } ## If this heading has graphs and we're supposed to show graphs, start that table. if ($num_graphs[$leaf[order_key]] > 0 && ! $no_graphs) { $need_table_close = true; print "\n"; } else { $need_table_close = false; } $graph_ct = 0; } else { ++$graph_ct; switch ($array_settings["hierarchical"]["viewtype"]) { case "1": print ""; break; } if ($graph_ct % 2 == 0) { print "\n"; } } } } DrawMatrixTableEnd(); } ?>
$leaf[Title]\n"; break; case "2": print "$leaf[title]