0) { foreach ($input_fields as $input_field) { /* save the data into the 'host_template_data' table */ $form_value = "value_" . $input_field["data_name"]; $form_value = $_POST[$form_value]; $form_is_templated_value = "t_value_" . $input_field["data_name"]; if (isset($_POST[$form_is_templated_value])) { if ((!empty($form_value)) || (!empty($_POST[$form_is_templated_value]))) { db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values (" . $input_field["id"] . ",$data_template_data_id,'" . $_POST[$form_is_templated_value] . "','$form_value')"); } } } } /* push out all "custom data" for this data source template */ push_out_data_template($data_template_id); } } if ((is_error_message()) || (empty($_POST["data_template_id"]))) { header ("Location: data_templates.php?action=template_edit&id=" . (empty($data_template_id) ? $_POST["data_template_id"] : $data_template_id)) . "&view_rrd=" . ($_POST["current_rrd"] ? $_POST["current_rrd"] : $data_template_rrd_id); }else{ header ("Location: data_templates.php"); } } } /* ---------------------------- template - Graph Templates ---------------------------- */ function template_remove() { if ((read_config_option("remove_verification") == "on") && (!isset($_GET["confirm"]))) { include ('include/top_header.php'); form_confirm("Are You Sure?", "Are you sure you want to delete the data template '" . db_fetch_cell("select name from data_template where id=" . $_GET["id"]) . "'? This is generally not a good idea if you have data sources attached to this template even though it should not affect any data sources.", getenv("HTTP_REFERER"), "data_templates.php?action=template_remove&id=" . $_GET["id"]); include ('include/bottom_footer.php'); exit; } if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) { db_execute("delete from data_template_data_rra where data_template_data_id=" . db_fetch_cell("select id from data_template_data where data_template_id=" . $_GET["id"])); db_execute("delete from data_template_data where data_template_id=" . $_GET["id"] . " and local_graph_id=0"); db_execute("delete from data_template_rrd where data_template_id=" . $_GET["id"] . " and local_graph_id=0"); db_execute("delete from data_template where id=" . $_GET["id"]); /* "undo" any graph that is currently using this template */ db_execute("update data_template_data set local_data_template_data_id=0,data_template_id=0 where data_template_id=" . $_GET["id"]); db_execute("update data_template_rrd set local_data_template_rrd_id=0,data_template_id=0 where data_template_id=" . $_GET["id"]); } } function template_rrd_remove() { db_execute("delete from data_template_rrd where id=" . $_GET["id"]); header ("Location: data_templates.php?action=template_edit&id=" . $_GET["data_template_id"]); } function template_rrd_add() { db_execute("insert into data_template_rrd (data_template_id,rrd_maximum,rrd_minimum,rrd_heartbeat,data_source_type_id, data_source_name) values (" . $_GET["id"] . ",100,0,600,1,'ds')"); $data_template_rrd_id = db_fetch_insert_id(); header ("Location: data_templates.php?action=template_edit&id=" . $_GET["id"] . "&view_rrd=$data_template_rrd_id"); } function template_edit() { global $colors, $struct_data_source, $struct_data_source_item, $data_source_types; if (!empty($_GET["id"])) { $template_data = db_fetch_row("select * from data_template_data where data_template_id=" . $_GET["id"] . " and local_data_id=0"); $template = db_fetch_row("select * from data_template where id=" . $_GET["id"]); $header_label = "[edit: " . $template["name"] . "]"; }else{ $header_label = "[new]"; } start_box("Data Template $header_label", "98%", $colors["header"], "3", "center", ""); ?>