function api_graph_tree_item_list($graph_tree_id, $filter_array = "", $limit_sub_tree_id = "", $show_sub_tree_parent = false, $show_sub_tree_children = true, $current_page = 0, $rows_per_page = 0) { /* sanity checks */ validate_id_die($graph_tree_id, "graph_tree_id"); require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_form.php"); $sql_where = ""; /* validation and setup for the WHERE clause */ if ((is_array($filter_array)) && (sizeof($filter_array) > 0)) { /* validate each field against the known master field list */ $field_errors = api_graph_tree_item_fields_validate(sql_filter_array_to_field_array($filter_array)); /* if a field input error has occured, register the error in the session and return */ if (sizeof($field_errors) > 0) { field_register_error($field_errors); return false; /* otherwise, form an SQL WHERE string using the filter fields */ }else{ $sql_where = sql_filter_array_to_where_string($filter_array, api_graph_tree_item_form_list(), false); } } $sql_limit = ""; /* validation and setup for the LIMIT clause */ if ((is_numeric($current_page)) && (is_numeric($rows_per_page)) && (!empty($current_page)) && (!empty($rows_per_page))) { $sql_limit = "limit " . ($rows_per_page * ($current_page - 1)) . ",$rows_per_page"; } /* only show tree items under this item if specified */ if (db_integer_validate($limit_sub_tree_id, false, false)) { $graph_tree_item = api_graph_tree_item_get($limit_sub_tree_id); $search_key = substr($graph_tree_item["order_key"], 0, (api_graph_tree_item_depth_get($graph_tree_item["order_key"]) * CHARS_PER_TIER)); if ($show_sub_tree_children == true) { $sql_where .= "and graph_tree_items.order_key like '$search_key%%'"; }else{ $sql_where .= " and graph_tree_items.order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'"; } if ($show_sub_tree_parent == false) { $sql_where .= "and graph_tree_items.id != $limit_sub_tree_id"; } } return db_fetch_assoc("select graph_tree_items.id, graph_tree_items.order_key, graph_tree_items.sort_children_type, graph_tree_items.device_grouping_type, graph_tree_items.item_type, graph_tree_items.item_value, graph.title_cache as graph_title, host.description as host_description, host.hostname as host_hostname from graph_tree_items left join graph on (graph_tree_items.item_value = graph.id and graph_tree_items.item_type = " . TREE_ITEM_TYPE_GRAPH . ") left join host on (graph_tree_items.item_value = host.id and graph_tree_items.item_type = " . TREE_ITEM_TYPE_HOST . ") where graph_tree_items.graph_tree_id = " . sql_sanitize($graph_tree_id) . " $sql_where order by graph_tree_items.order_key $sql_limit"); }
function api_graph_tree_item_move($graph_tree_item_id, $direction) { require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_info.php"); /* sanity checks */ validate_id_die($graph_tree_item_id, "graph_tree_item_id"); if (($direction != "up") && ($direction != "down")) { return false; } /* obtain a copy of the current graph tree item */ $graph_tree_item = api_graph_tree_item_get($graph_tree_item_id); /* find out where in the tree this item is located */ $current_depth = api_graph_tree_item_depth_get($graph_tree_item["order_key"]); $displaced_row = db_fetch_row("select order_key from graph_tree_items where order_key " . ($direction == "up" ? "<" : ">") . " " . sql_sanitize($graph_tree_item["order_key"]) . " and order_key like '%" . sql_sanitize(substr($graph_tree_item["order_key"], ($current_depth * CHARS_PER_TIER))) . "' and order_key not like '%" . sql_sanitize(str_repeat('0', CHARS_PER_TIER) . substr($graph_tree_item["order_key"], ($current_depth * CHARS_PER_TIER))) . "' and graph_tree_id = " . $graph_tree_item["graph_tree_id"] . " order by order_key " . ($direction == "up" ? "DESC" : "ASC")); if ((is_array($displaced_row)) && (isset($displaced_row["order_key"]))) { $old_root = sql_sanitize(substr($graph_tree_item["order_key"], 0, ($current_depth * CHARS_PER_TIER))); $new_root = sql_sanitize(substr($displaced_row["order_key"], 0, ($current_depth * CHARS_PER_TIER))); db_execute("UPDATE graph_tree_items SET order_key = CONCAT('" . str_pad('', ($current_depth * CHARS_PER_TIER), 'Z') . "',SUBSTRING(order_key," . (($current_depth * CHARS_PER_TIER) + 1).")) WHERE order_key LIKE '$new_root%' AND graph_tree_id = " . $graph_tree_item["graph_tree_id"]); db_execute("UPDATE graph_tree_items SET order_key = CONCAT('$new_root',SUBSTRING(order_key," . (($current_depth * CHARS_PER_TIER) + 1) . ")) WHERE order_key LIKE '$old_root%' AND graph_tree_id = " . $graph_tree_item["graph_tree_id"]); db_execute("UPDATE graph_tree_items SET order_key = CONCAT('$old_root',SUBSTRING(order_key," . (($current_depth * CHARS_PER_TIER) + 1) . ")) WHERE order_key LIKE '" . str_pad('', ($current_depth * CHARS_PER_TIER), 'Z') . "%' AND graph_tree_id = " . $graph_tree_item["graph_tree_id"]); } }
function api_graph_tree_item_available_order_key_get($graph_tree_id, $order_key) { /* sanity checks */ validate_id_die($graph_tree_id, "graph_tree_id"); if (($order_key != "") && (!api_graph_tree_item_order_key_validate($order_key))) { die("Invalid order key '$order_key'"); } if (preg_match("/^" . str_repeat('0', CHARS_PER_TIER) . "/", $order_key)) { $tier = 0; $parent_root = ''; }else{ $tier = api_graph_tree_item_depth_get($order_key); $parent_root = substr($order_key, 0, ($tier * CHARS_PER_TIER)); } $order_key = db_fetch_cell("SELECT order_key FROM graph_tree_items WHERE graph_tree_id = $graph_tree_id AND order_key LIKE '$parent_root%' ORDER BY order_key DESC LIMIT 1"); $complete_root = substr($order_key, 0, ($tier * CHARS_PER_TIER) + CHARS_PER_TIER); $order_key_suffix = (substr($complete_root, - CHARS_PER_TIER) + 1); $order_key_suffix = str_pad($order_key_suffix, CHARS_PER_TIER, '0', STR_PAD_LEFT); $order_key_suffix = str_pad($parent_root . $order_key_suffix, (MAX_TREE_DEPTH * CHARS_PER_TIER), '0', STR_PAD_RIGHT); return $order_key_suffix; }
function api_tree_item_save($id, $tree_id, $type, $parent_tree_item_id, $title, $local_graph_id, $rra_id, $host_id, $host_grouping_type, $sort_children_type, $propagate_changes) { require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_utility.php"); $parent_order_key = db_fetch_cell("select order_key from graph_tree_items where id=$parent_tree_item_id"); /* fetch some cache variables */ if (empty($id)) { /* new/save - generate new order key */ $order_key = api_graph_tree_item_available_order_key_get($parent_order_key, "graph_tree_items", "order_key", "graph_tree_id=$tree_id"); }else{ /* edit/save - use old order_key */ $order_key = db_fetch_cell("select order_key from graph_tree_items where id=$id"); } /* duplicate graph check */ $search_key = substr($parent_order_key, 0, (api_graph_tree_item_depth_get($parent_order_key) * CHARS_PER_TIER)); if (($type == TREE_ITEM_TYPE_GRAPH) && (sizeof(db_fetch_assoc("select id from graph_tree_items where local_graph_id='$local_graph_id' and graph_tree_id='$tree_id' and order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "'")) > 0)) { return 0; } $save["id"] = $id; $save["graph_tree_id"] = $tree_id; $save["title"] = form_input_validate($title, "title", "", ($type == TREE_ITEM_TYPE_HEADER ? false : true), 3); $save["order_key"] = $order_key; $save["local_graph_id"] = form_input_validate($local_graph_id, "local_graph_id", "", true, 3); $save["rra_id"] = form_input_validate($rra_id, "rra_id", "", true, 3); $save["host_id"] = form_input_validate($host_id, "host_id", "", true, 3); $save["host_grouping_type"] = form_input_validate($host_grouping_type, "host_grouping_type", "", true, 3); $save["sort_children_type"] = form_input_validate($sort_children_type, "sort_children_type", "", true, 3); $tree_item_id = 0; if (!is_error_message()) { $tree_item_id = sql_save($save, "graph_tree_items"); if ($tree_item_id) { raise_message(1); /* re-parent the branch if the parent item has changed */ if ($parent_tree_item_id != $tree_item_id) { reparent_branch($tree_item_id, $parent_tree_item_id); } $tree_sort_type = db_fetch_cell("select sort_type from graph_tree where id='$tree_id'"); /* tree item ordering */ if ($tree_sort_type == TREE_ORDERING_NONE) { /* resort our parent */ $parent_sorting_type = db_fetch_cell("select sort_children_type from graph_tree_items where id=$parent_tree_item_id"); if ((!empty($parent_tree_item_id)) && ($parent_sorting_type != TREE_ORDERING_NONE)) { sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $parent_sorting_type); } /* if this is a header, sort direct children */ if (($type == TREE_ITEM_TYPE_HEADER) && ($sort_children_type != TREE_ORDERING_NONE)) { sort_tree(SORT_TYPE_TREE_ITEM, $tree_item_id, $sort_children_type); } /* tree ordering */ }else{ /* potential speed savings for large trees */ if (api_graph_tree_item_depth_get($save["order_key"]) == 1) { sort_tree(SORT_TYPE_TREE, $tree_id, $tree_sort_type); }else{ sort_tree(SORT_TYPE_TREE_ITEM, $parent_tree_item_id, $tree_sort_type); } } /* if the user checked the 'Propagate Changes' box */ if (($type == TREE_ITEM_TYPE_HEADER) && ($propagate_changes == true)) { $search_key = preg_replace("/0+$/", "", $order_key); $tree_items = db_fetch_assoc("select graph_tree_items.id from graph_tree_items where graph_tree_items.host_id = 0 and graph_tree_items.local_graph_id = 0 and graph_tree_items.title != '' and graph_tree_items.order_key like '$search_key%%' and graph_tree_items.graph_tree_id='$tree_id'"); if (sizeof($tree_items) > 0) { foreach ($tree_items as $item) { db_execute("update graph_tree_items set sort_children_type = '$sort_children_type' where id = '" . $item["id"] . "'"); if ($sort_children_type != TREE_ORDERING_NONE) { sort_tree(SORT_TYPE_TREE_ITEM, $item["id"], $sort_children_type); } } } } }else{ raise_message(2); } } return $tree_item_id; }
function grow_right_pane_tree($tree_id, $leaf_id, $host_group_data) { global $current_user, $colors; require_once(CACTI_BASE_PATH . "/lib/data_query/data_query_info.php"); require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_utility.php"); if (empty($tree_id)) { return; } $sql_where = ""; $sql_join = ""; $title = ""; $title_delimiter = ""; $search_key = ""; $leaf = db_fetch_row("select order_key,title,host_id,host_grouping_type from graph_tree_items where id=$leaf_id"); $leaf_type = get_tree_item_type($leaf_id); /* get the "starting leaf" if the user clicked on a specific branch */ if (!empty($leaf_id)) { $search_key = substr($leaf["order_key"], 0, (api_graph_tree_item_depth_get($leaf["order_key"]) * CHARS_PER_TIER)); } /* graph permissions */ if (read_config_option("auth_method") != "0") { /* get policy information for the sql where clause */ $sql_where = get_graph_permissions_sql($current_user["policy_graphs"], $current_user["policy_hosts"], $current_user["policy_graph_templates"]); $sql_where = (empty($sql_where) ? "" : "and $sql_where"); $sql_join = " left join host on (host.id=graph.host_id) left join graph_template on (graph_template.id=graph.graph_template_id) left join user_auth_perms on ((graph.id=user_auth_perms.item_id and user_auth_perms.type=1 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (host.id=user_auth_perms.item_id and user_auth_perms.type=3 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . ") OR (graph_template.id=user_auth_perms.item_id and user_auth_perms.type=4 and user_auth_perms.user_id=" . $_SESSION["sess_user_id"] . "))"; } /* get information for the headers */ if (!empty($tree_id)) { $tree_name = db_fetch_cell("select name from graph_tree where id=$tree_id"); } if (!empty($leaf_id)) { $leaf_name = $leaf["title"]; } if (!empty($leaf_id)) { $host_name = db_fetch_cell("select host.description from (graph_tree_items,host) where graph_tree_items.host_id=host.id and graph_tree_items.id=$leaf_id"); } $host_group_data_array = explode(":", $host_group_data); if ($host_group_data_array[0] == "graph_template") { $host_group_data_name = "<strong>" . _("Graph Template:") . "</strong> " . db_fetch_cell("select template_name from graph_template where id=" . $host_group_data_array[1]); $graph_template_id = $host_group_data_array[1]; }elseif ($host_group_data_array[0] == "data_query") { $host_group_data_name = "<strong>" . _("Data Query:") . "</strong> " . (empty($host_group_data_array[1]) ? _("(Non Indexed)") : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1])); $data_query_id = $host_group_data_array[1]; }elseif ($host_group_data_array[0] == "data_query_index") { $host_group_data_name = "<strong>" . _("Data Query:") . "</strong> " . (empty($host_group_data_array[1]) ? _("(Non Indexed)") : db_fetch_cell("select name from snmp_query where id=" . $host_group_data_array[1])) . "-> " . (empty($host_group_data_array[2]) ? "Unknown Index" : get_formatted_data_query_index($leaf["host_id"], $host_group_data_array[1], $host_group_data_array[2])); $data_query_id = $host_group_data_array[1]; $data_query_index = $host_group_data_array[2]; } if (!empty($tree_name)) { $title .= $title_delimiter . "<strong>" . _("Tree:") . "</strong> $tree_name"; $title_delimiter = "-> "; } if (!empty($leaf_name)) { $title .= $title_delimiter . "<strong>" . _("Leaf:") . "</strong> $leaf_name"; $title_delimiter = "-> "; } if (!empty($host_name)) { $title .= $title_delimiter . "<strong>" . _("Device:") . "</strong> $host_name"; $title_delimiter = "-> "; } if (!empty($host_group_data_name)) { $title .= $title_delimiter . " $host_group_data_name"; $title_delimiter = "-> "; } print "<table width='98%' align='center' cellpadding='3'>"; /* include time span selector */ if (read_graph_config_option("timespan_sel") == "on") { html_graph_start_box(3, false); require(CACTI_BASE_PATH . "/include/html/inc_timespan_selector.php"); html_graph_end_box(); print "<br>"; } /* start graph display */ html_graph_start_box(3, false); print "<tr bgcolor='#" . $colors["header_panel_background"] . "'><td width='390' colspan='3' class='textHeaderDark'>$title</td></tr>"; if (($leaf_type == "header") || (empty($leaf_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.title_cache from (graph_tree_items,graph) left join graph on (graph_tree_items.local_graph_id=graph.id) $sql_join where graph_tree_items.graph_tree_id=$tree_id and graph_tree_items.order_key like '$search_key" . str_repeat('_', CHARS_PER_TIER) . str_repeat('0', (MAX_TREE_DEPTH * CHARS_PER_TIER) - (strlen($search_key) + CHARS_PER_TIER)) . "' and graph_tree_items.local_graph_id>0 $sql_where group by graph_tree_items.id order by graph_tree_items.order_key"); if (read_graph_config_option("thumbnail_section_tree_2") == "on") { html_graph_thumbnail_area($heirarchy, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end()); }else{ html_graph_area($heirarchy, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end()); } }elseif ($leaf_type == "host") { /* graph template grouping */ if ($leaf["host_grouping_type"] == HOST_GROUPING_GRAPH_TEMPLATE) { $graph_templates = db_fetch_assoc("select graph_template.id, graph_template.template_name from graph,graph_template where graph.graph_template_id=graph_template.id and graph.host_id=" . $leaf["host_id"] . " " . (empty($graph_template_id) ? "" : "and graph_template.id=$graph_template_id") . " group by graph_template.id order by graph_template.template_name"); /* for graphs without a template */ array_push($graph_templates, array( "id" => "0", "template_name" => _("(No Graph Template)") )); if (sizeof($graph_templates) > 0) { foreach ($graph_templates as $item) { $graphs = db_fetch_assoc("select graph.title_cache, graph.id as graph_id from graph $sql_join where graph.graph_template_id=" . $item["id"] . " and graph.host_id=" . $leaf["host_id"] . " $sql_where order by graph.title_cache"); if (read_graph_config_option("thumbnail_section_tree_2") == "on") { html_graph_thumbnail_area($graphs, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end(), "<tr bgcolor='#" . $colors["graph_type_background"] . "'><td colspan='3' class='textHeaderDark'><strong>" . _("Graph Template:") . "</strong> " . $item["template_name"] . "</td></tr>"); }else{ html_graph_area($graphs, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end(), "<tr bgcolor='#" . $colors["graph_type_background"] . "'><td colspan='3' class='textHeaderDark'><strong>" . _("Graph Template:") . "</strong> " . $item["template_name"] . "</td></tr>"); } } } /* data query index grouping */ }elseif ($leaf["host_grouping_type"] == HOST_GROUPING_DATA_QUERY_INDEX) { $data_sources = db_fetch_assoc("select graph.id as graph_id, graph.title_cache as graph_title, data_source.data_input_type, data_source.id as data_source_id from graph,graph_item,data_source_item,data_source where graph.id=graph_item.graph_id and graph_item.data_source_item_id=data_source_item.id and data_source_item.data_source_id=data_source.id and graph.host_id = " . $leaf["host_id"] . ""); $index_list = array(); if (sizeof($data_sources) > 0) { foreach ($data_sources as $item) { if ($item["data_input_type"] == DATA_INPUT_TYPE_DATA_QUERY) { $field_list = array_rekey(db_fetch_assoc("select name,value from data_source_field where data_source_id = ". $item["data_source_id"] . " and (name = 'data_query_id' or name = 'data_query_index' or name = 'data_query_field_name' or name = 'data_query_field_value')"), "name", "value"); if ((isset($field_list["data_query_id"])) && (isset($field_list["data_query_index"]))) { if ( !(((isset($data_query_id)) && ($data_query_id != $field_list["data_query_id"])) || ((isset($data_query_index)) && ($data_query_index != $field_list["data_query_index"]))) ) { $index_list{$field_list["data_query_id"]}{$field_list["data_query_index"]}{$item["graph_id"]} = $item["graph_title"]; } } }else{ $index_list[0][0]{$item["graph_id"]} = $item["graph_title"]; } } } while (list($data_query_id, $graph_list) = each($index_list)) { if (empty($data_query_id)) { print "<tr bgcolor='#" . $colors["graph_type_background"] . "'><td colspan='3' class='textHeaderDark'><strong>" . _("(Non Indexed)") . "</strong></td></tr>"; $index_graph_list = array(); while (list($graph_id, $graph_title) = each($graph_list[0])) { /* reformat the array so it's compatable with the html_graph* area functions */ array_push($index_graph_list, array("graph_id" => $graph_id, "title_cache" => $graph_title)); } if (read_graph_config_option("thumbnail_section_tree_2") == "on") { html_graph_thumbnail_area($index_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end(), ""); }else{ html_graph_area($index_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end(), ""); } }else{ /* fetch a list of field names that are sorted by the preferred sort field */ $sort_field_data = get_formatted_data_query_indexes($leaf["host_id"], $data_query_id); /* re-key the results on data query index */ if (sizeof($graph_list) > 0) { print "<tr bgcolor='#" . $colors["graph_type_background"] . "'><td colspan='3' class='textHeaderDark'><strong>" . _("Data Query:") . "</strong> " . db_fetch_cell("select name from snmp_query where id = $data_query_id") . "</td></tr>"; } /* using the sorted data as they key; grab each snmp index from the master list */ while (list($data_query_index, $sort_field_value) = each($sort_field_data)) { /* render each graph for the current data query index */ if (isset($graph_list[$data_query_index])) { $index_graph_list = array(); while (list($graph_id, $graph_title) = each($graph_list[$data_query_index])) { /* reformat the array so it's compatable with the html_graph* area functions */ array_push($index_graph_list, array("graph_id" => $graph_id, "title_cache" => $graph_title)); } if (read_graph_config_option("thumbnail_section_tree_2") == "on") { html_graph_thumbnail_area($index_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end(), "<tr bgcolor='#" . $colors["graph_type_background"] . "'><td colspan='3' class='textHeaderDark'>$sort_field_value</td></tr>"); }else{ html_graph_area($index_graph_list, "", "view_type=tree&graph_start=" . get_current_graph_start() . "&graph_end=" . get_current_graph_end(), "<tr bgcolor='#" . $colors["graph_type_background"] . "'><td colspan='3' class='textHeaderDark'>$sort_field_value</td></tr>"); } } } } } } } print "</table>"; }
function tree_edit() { $menu_items = array("remove" => "Remove"); $_graph_tree_id = get_get_var_number("id"); if (empty($_graph_tree_id)) { $header_label = "[new]"; } else { $graph_tree = api_graph_tree_get($_graph_tree_id); $header_label = "[edit: " . $graph_tree["name"] . "]"; } form_start("graph_trees.php", "form_graph_tree"); html_start_box("<strong>" . _("Graph Trees") . "</strong> {$header_label}", ""); _graph_tree_field__name("name", isset($graph_tree["name"]) ? $graph_tree["name"] : "", empty($_graph_tree_id) ? 0 : $_graph_tree_id); _graph_tree_field__sort_type("sort_type", isset($graph_tree["sort_type"]) ? $graph_tree["sort_type"] : "", empty($_graph_tree_id) ? 0 : $_graph_tree_id); html_end_box(); form_hidden_box("id", $_graph_tree_id); form_hidden_box("action_post", "graph_tree_edit"); form_save_button("graph_trees.php"); if (!empty($_graph_tree_id)) { echo "<br />\n"; form_start("graph_trees_items.php", "form_graph_tree_item"); $box_id = "1"; html_start_box("<strong>" . _("Tree Items") . "</strong>", "graph_trees_items.php?action=edit&tree_id=" . $_graph_tree_id . "&parent_id=0"); html_header_checkbox(array(_("Item"), _("Type"), ""), $box_id, "1"); /* get a sorted list of all graph items inside of this tree */ $tree_items = api_graph_tree_item_list($_graph_tree_id); /* get a list of available types (header, host, graph, etc) */ $tree_item_types = api_graph_tree_item_type_list(); if (is_array($tree_items) > 0 && sizeof($tree_items) > 0) { foreach ($tree_items as $tree_item) { $current_depth = api_graph_tree_item_depth_get($tree_item["order_key"]); /* keep track of the current item's sort type so we know whether to display sort * arrays for items children or not */ $sort_cache[$current_depth] = $tree_item["sort_children_type"]; $transparent_indent = ""; if ($tree_item["item_type"] == TREE_ITEM_TYPE_GRAPH) { $item_text = $tree_item["graph_title"]; } else { if ($tree_item["item_type"] == TREE_ITEM_TYPE_HEADER) { $item_text = "<strong>" . $tree_item["item_value"] . "</strong></a> (<a href='graph_trees_items.php?action=edit&tree_id=" . $_graph_tree_id . "&parent_id=" . $tree_item["id"] . "'>Add</a>)"; } else { if ($tree_item["item_type"] == TREE_ITEM_TYPE_HOST) { $item_text = "<strong>Device:</strong> " . $tree_item["host_hostname"]; } } } ?> <tr class="item" id="box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> " onClick="display_row_select('<?php echo $box_id; ?> ',document.forms[1],'box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ', 'box-<?php echo $box_id; ?> -chk-<?php echo $tree_item["id"]; ?> ')" onMouseOver="display_row_hover('box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ')" onMouseOut="display_row_clear('box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ')"> <td class="title"> <img width="<?php echo ($current_depth - 1) * 20; ?> " height="1" align="middle" alt=""> <a onClick="display_row_block('box-<?php echo $box_id; ?> -row-<?php echo $tree_item["id"]; ?> ')" href="graph_trees_items.php?action=edit&tree_id=<?php echo $_graph_tree_id; ?> &id=<?php echo $tree_item["id"]; ?> "><span id="box-<?php echo $box_id; ?> -text-<?php echo $tree_item["id"]; ?> "><?php echo html_highlight_words(get_get_var("search_filter"), $item_text); ?> </span></a> </td> <td> <?php echo $tree_item_types[$tree_item["item_type"]]; ?> </td> <?php if (isset($sort_cache[$current_depth - 1]) && $sort_cache[$current_depth - 1] != TREE_ORDERING_NONE || $graph_tree["sort_type"] != TREE_ORDERING_NONE) { ?> <td width="80"> </td> <?php } else { ?> <td width="80" align="center"> <a href="graph_trees_items.php?action=movedown&id=<?php echo $tree_item["id"]; ?> &graph_tree_id=<?php echo $_graph_tree_id; ?> "><img src="<?php echo html_get_theme_images_path("move_down.gif"); ?> " border="0" alt="Move Down"></a> <a href="graph_trees_items.php?action=moveup&id=<?php echo $tree_item["id"]; ?> &graph_tree_id=<?php echo $_graph_tree_id; ?> "><img src="<?php echo html_get_theme_images_path("move_up.gif"); ?> " border="0" alt="Move Up"></a> </td> <?php } ?> <td class="checkbox" align="center"> <input type='checkbox' name='box-<?php echo $box_id; ?> -chk-<?php echo $tree_item["id"]; ?> ' id='box-<?php echo $box_id; ?> -chk-<?php echo $tree_item["id"]; ?> ' title="<?php echo strip_tags($item_text); ?> "> </td> </tr> <?php } } else { ?> <tr class="empty"> <td colspan="6"> No graph tree items found. </td> </tr> <?php } html_box_toolbar_draw($box_id, "1", "3", HTML_BOX_SEARCH_NONE); html_end_box(false); html_box_actions_menu_draw($box_id, "1", $menu_items); form_hidden_box("graph_tree_id", $_graph_tree_id); form_hidden_box("action", "save"); form_hidden_box("action_post", "graph_tree_item_list"); form_end(); ?> <script language="JavaScript"> <!-- function action_area_handle_type(box_id, type, parent_div, parent_form) { if (type == 'remove') { parent_div.appendChild(document.createTextNode('Are you sure you want to remove these graph tree items?')); parent_div.appendChild(action_area_generate_selected_rows(box_id)); action_area_update_header_caption(box_id, 'Remove Graph Tree Item'); action_area_update_submit_caption(box_id, 'Remove'); action_area_update_selected_rows(box_id, parent_form); } } --> </script> <?php } }