/* +-------------------------------------------------------------------------+ | Copyright (C) 2002 Ian Berry | | | | This program is free software; you can redistribute it and/or | | modify it under the terms of the GNU General Public License | | as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | +-------------------------------------------------------------------------+ | cacti: the rrdtool frontend [php-auth, php-tree, php-form] | +-------------------------------------------------------------------------+ | This code is currently maintained and debugged by Ian Berry, any | | questions or comments regarding this code should be directed to: | | - iberry@raxnet.net | +-------------------------------------------------------------------------+ | - raXnet - http://www.raxnet.net/ | +-------------------------------------------------------------------------+ */?> $section = "Add/Edit Graphs"; include ('include/auth.php'); include_once ('include/form.php'); include_once ('include/functions.php'); if ($form[action]) { $action = $form[action]; } else { $action = $args[action]; } if ($form[ID]) { $id = $form[ID]; } else { $id = $args[id]; } switch ($action) { case 'save': $redirect_location = form_save(); header ("Location: $redirect_location"); exit; break; case 'item_movedown': item_movedown(); header ("Location: " . getenv("HTTP_REFERER")); break; case 'item_moveup': item_moveup(); header ("Location: " . getenv("HTTP_REFERER")); break; case 'item_edit': include_once ("include/top_header.php"); item_edit(); include_once ("include/bottom_footer.php"); break; case 'remove': tree_remove(); header ("Location: tree.php"); break; case 'edit': include_once ("include/top_header.php"); tree_edit(); include_once ("include/bottom_footer.php"); break; default: include_once ("include/top_header.php"); tree(); include_once ("include/bottom_footer.php"); break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { global $form; if (isset($form[save_component_tree])) { tree_save(); return "tree.php"; }elseif (isset($form[save_component_tree_item])) { item_save(); return "tree.php?action=edit&id=$form[tree_id]"; } } /* ----------------------- Tree Item Functions ----------------------- */ function item_edit() { global $args, $colors, $cdef_item_types; if (isset($args[tree_item_id])) { $tree_item = db_fetch_row("select * from graph_tree_view_items where id=$args[tree_item_id]"); }else{ unset($tree_item); } /* bold the active "type" */ if ($tree_item[graph_id] > 0) { $title = "Tree Item [graph]"; }else{ $title = "Tree Item [graph]"; } start_box($title, "", ""); ?>
end_box(); } function item_moveup() { include_once('include/tree_functions.php'); global $args; $order_key = db_fetch_cell("SELECT order_key FROM graph_tree_view_items WHERE id=$args[tree_item_id]"); if ($order_key > 0) { branch_up($order_key, 'graph_tree_view_items', 'order_key', ''); } } function item_movedown() { include_once('include/tree_functions.php'); global $args; $order_key = db_fetch_cell("SELECT order_key FROM graph_tree_view_items WHERE id=$args[tree_item_id]"); if ($order_key > 0) { branch_down($order_key, 'graph_tree_view_items', 'order_key', ''); } } /* --------------------- Tree Functions --------------------- */ function tree_save() { global $form; $save["id"] = $form["id"]; $save["name"] = $form["name"]; if (sql_Save($save, "graph_tree_view")) { raise_message(1); }else{ raise_message(2); header("Location: " . $_SERVER["HTTP_REFERER"]); exit; } } function tree_remove() { global $args, $config; if (($config["remove_verification"]["value"] == "on") && ($args[confirm] != "yes")) { include ('include/top_header.php'); DrawConfirmForm("Are You Sure?", "Are you sure you want to delete the tree '" . db_fetch_cell("select name from graph_tree_view where id=$args[id]") . "'?", getenv("HTTP_REFERER"), "tree.php?action=remove&id=$args[id]"); include ('include/bottom_footer.php'); exit; } if (($config["remove_verification"]["value"] == "") || ($args[confirm] == "yes")) { db_execute("delete from graph_tree_view where id=$args[id]"); } } function tree_edit() { include_once("include/tree_view_functions.php"); global $args, $colors, $cdef_item_types; start_box("Trees [edit]", "", ""); if (isset($args[id])) { $tree = db_fetch_row("select * from graph_tree_view where id=$args[id]"); }else{ unset($tree); } ?> end_box(); } function tree() { global $colors; start_box("Graph Trees", "", "tree.php?action=edit"); print "