function draw_nontemplated_fields_graph_item($graph_template_id, &$values_array, $field_name_format = "|field|_|id|", $display_template_name = true) { global $colors; require_once(CACTI_BASE_PATH . "/lib/graph/graph_form.php"); if (empty($graph_template_id)) { return; } $num_draw_fields = 0; /* fetch information about the graph template (for the template name) */ $graph_template = db_fetch_row("select * from graph_template where id = $graph_template_id"); /* fetch a list of graph item inputs for this graph template */ $graph_template_item_inputs = db_fetch_assoc("select * from graph_template_item_input where graph_template_id = $graph_template_id order by field_name,name"); if (sizeof($graph_template_item_inputs) > 0) { foreach ($graph_template_item_inputs as $item) { /* substitute the graph item input id in the field name */ $_field_name_format = str_replace("|id|", $item["id"], $field_name_format); /* grab the first graph template item referenced by this graph item input */ $first_graph_template_item_id = db_fetch_cell("select graph_template_item_id from graph_template_item_input_item where graph_template_item_input_id = " . $item["id"] . " limit 1"); if ((!empty($first_graph_template_item_id)) && (isset($values_array[$first_graph_template_item_id]))) { /* find our field name */ $form_field_name = str_replace("|field|", $item["field_name"], $field_name_format); $form_field_name = str_replace("|id|", $item["id"], $form_field_name); if ($item["field_name"] == "color") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__color(str_replace("|field|", "color", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "graph_item_type") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__graph_item_type(str_replace("|field|", "graph_item_type", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "consolidation_function") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__consolidation_function(str_replace("|field|", "consolidation_function", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "cdef") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__cdef(str_replace("|field|", "cdef", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "gprint_format") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__gprint_format(str_replace("|field|", "gprint_format", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "legend_value") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__legend_value(str_replace("|field|", "legend_value", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "legend_format") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__legend_format(str_replace("|field|", "legend_format", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } if ($item["field_name"] == "hard_return") { $num_draw_fields = template_form_header_precheck($num_draw_fields, "<strong>" . _("Graph Item") . "</strong>", ($display_template_name == true ? $graph_template["template_name"] : "")); _graph_item_field__hard_return(str_replace("|field|", "hard_return", $_field_name_format), $values_array[$first_graph_template_item_id]{$item["field_name"]}, 1); } } } } return $num_draw_fields; }
function item_edit() { global $colors; if (!empty($_GET["id"])) { $graph_template_item = db_fetch_row("select * from graph_template_item where id=" . $_GET["id"]); } /* by default, select the LAST DS chosen to make everyone's lives easier */ $default = db_fetch_row("select data_template_item_id from graph_template_item where graph_template_id=" . $_GET["graph_template_id"] . " order by sequence DESC"); if (sizeof($default) > 0) { $graph_template_item["data_template_item_id"] = $default["data_template_item_id"]; } else { $graph_template_item["data_template_item_id"] = 0; } form_start("graph_templates_items.php", "form_graph_template"); /* ==================== Box: Graph Item ==================== */ html_start_box("<strong>" . _("Graph Item") . "</strong> [" . _("Graph Template: ") . db_fetch_cell("select template_name from graph_template where id=" . $_GET["graph_template_id"]) . "]", "98%", $colors["header_background"], "3", "center", ""); _graph_item_field__data_template_item_id("data_template_item_id", isset($graph_template_item["data_template_item_id"]) ? $graph_template_item["data_template_item_id"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__color("color", isset($graph_template_item["color"]) ? $graph_template_item["color"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__graph_item_type("graph_item_type", isset($graph_template_item["graph_item_type"]) ? $graph_template_item["graph_item_type"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__consolidation_function("consolidation_function", isset($graph_template_item["consolidation_function"]) ? $graph_template_item["consolidation_function"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__cdef("cdef", isset($graph_template_item["cdef"]) ? $graph_template_item["cdef"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__gprint_format("gprint_format", isset($graph_template_item["gprint_format"]) ? $graph_template_item["gprint_format"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__legend_value("legend_value", isset($graph_template_item["legend_value"]) ? $graph_template_item["legend_value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__legend_format("legend_format", isset($graph_template_item["legend_format"]) ? $graph_template_item["legend_format"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__hard_return("hard_return", isset($graph_template_item["hard_return"]) ? $graph_template_item["hard_return"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); html_end_box(); form_hidden_box("graph_template_item_id", !empty($graph_template_item["id"]) ? $graph_template_item["id"] : "0", ""); form_hidden_box("graph_template_id", $_GET["graph_template_id"], "0"); form_hidden_box("save_component_item", "1", ""); form_save_button("graph_templates.php?action=edit&id=" . $_GET["graph_template_id"]); }
function item_edit() { global $colors; /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_ds_host_id"); unset($_REQUEST["host_id"]); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("filter", "sess_ds_filter", ""); load_current_session_value("host_id", "sess_ds_host_id", "-1"); $host = db_fetch_row("select hostname from host where id = " . sql_sanitize($_REQUEST["host_id"])); html_start_box("<strong>Data Source by Host</strong> [host: " . (empty($host["hostname"]) ? "No Host" : $host["hostname"]) . "]", "98%", $colors["header"], "3", "center", ""); include "./include/html/inc_graph_items_filter_table.php"; html_end_box(); if ($_REQUEST["host_id"] == "-1") { $sql_where = ""; } elseif ($_REQUEST["host_id"] == "0") { $sql_where = " and data_local.host_id = 0"; } elseif (!empty($_REQUEST["host_id"])) { $sql_where = " and data_local.host_id = " . sql_sanitize($_REQUEST["host_id"]); } if (!empty($_GET["id"])) { $graph_item = db_fetch_row("select * from graph_item where id = " . sql_sanitize($_GET["id"])); $host_id = db_fetch_cell("select host_id from graph where id = " . sql_sanitize($_GET["graph_id"])); } /* by default, select the LAST DS chosen to make everyone's lives easier */ $default = db_fetch_row("select data_source_item_id from graph_item where graph_id = " . sql_sanitize($_GET["graph_id"]) . " order by sequence DESC limit 1"); form_start("graphs_items.php", "form_graph_item"); /* ==================== Box: Graph Item ==================== */ html_start_box("<strong>" . _("Graph Item") . "</strong> [Graph: " . db_fetch_cell("select title_cache from graph where id=" . $_GET["graph_id"]) . "]", "98%", $colors["header_background"], "3", "center", ""); _graph_item_field__data_source_item_id("data_source_item_id", sizeof($default) == 1 ? $default["data_source_item_id"] : "0", empty($_GET["id"]) ? 0 : $_GET["id"], $host_id); _graph_item_field__color("color", isset($graph_item["color"]) ? $graph_item["color"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__graph_item_type("graph_item_type", isset($graph_item["graph_item_type"]) ? $graph_item["graph_item_type"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__consolidation_function("consolidation_function", isset($graph_item["consolidation_function"]) ? $graph_item["consolidation_function"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__cdef("cdef", isset($graph_item["cdef"]) ? $graph_item["cdef"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__gprint_format("gprint_format", isset($graph_item["gprint_format"]) ? $graph_item["gprint_format"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__legend_value("legend_value", isset($graph_item["legend_value"]) ? $graph_item["legend_value"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__legend_format("legend_format", isset($graph_item["legend_format"]) ? $graph_item["legend_format"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); _graph_item_field__hard_return("hard_return", isset($graph_item["hard_return"]) ? $graph_item["hard_return"] : "", empty($_GET["id"]) ? 0 : $_GET["id"]); form_hidden_box("graph_item_id", isset($graph_item) ? $graph_item["id"] : "0", ""); form_hidden_box("graph_id", $_GET["graph_id"], "0"); form_hidden_box("save_component_item", "1", ""); html_end_box(); form_save_button("graphs.php?action=edit&id=" . $_GET["graph_id"]); }