function form_actions() { global $colors, $graph_actions; /* if we are to save this form, instead of display it */ if (isset($_POST["selected_items"])) { $selected_items = unserialize(stripslashes($_POST["selected_items"])); if ($_POST["drp_action"] == "1") { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { if (!isset($_POST["delete_type"])) { $_POST["delete_type"] = 1; } switch ($_POST["delete_type"]) { case '2': /* delete all data sources referenced by this graph */ $data_sources = db_fetch_assoc("select distinct\n\t\t\t\t\t\t\tdata_source.id\n\t\t\t\t\t\t\tfrom data_source_item,data_source,graph_item\n\t\t\t\t\t\t\twhere graph_item.data_source_item_id=data_source_item.id\n\t\t\t\t\t\t\tand data_source_item.data_source_id=data_source.id\n\t\t\t\t\t\t\tand " . array_to_sql_or($selected_items, "graph_item.graph_id") . "\n\t\t\t\t\t\t\torder by data_source.name_cache"); if (sizeof($data_sources) > 0) { foreach ($data_sources as $data_source) { api_data_source_remove($data_source["id"]); } } break; } api_graph_remove($selected_items[$i]); } } elseif ($_POST["drp_action"] == "2") { /* change graph template */ for ($i = 0; $i < count($selected_items); $i++) { change_graph_template($selected_items[$i], $_POST["graph_template_id"], true); } } elseif ($_POST["drp_action"] == "3") { /* duplicate */ for ($i = 0; $i < count($selected_items); $i++) { duplicate_graph($selected_items[$i], 0, $_POST["title_format"]); } } elseif ($_POST["drp_action"] == "4") { /* graph -> graph template */ for ($i = 0; $i < count($selected_items); $i++) { graph_to_graph_template($selected_items[$i], $_POST["title_format"]); } } elseif (ereg("^tr_([0-9]+)\$", $_POST["drp_action"], $matches)) { /* place on tree */ for ($i = 0; $i < count($selected_items); $i++) { api_tree_item_save(0, $_POST["tree_id"], TREE_ITEM_TYPE_GRAPH, $_POST["tree_item_id"], "", $selected_items[$i], read_graph_config_option("default_rra_id"), 0, 0, 0, false); } } elseif ($_POST["drp_action"] == "5") { /* change host */ for ($i = 0; $i < count($selected_items); $i++) { db_execute("update graph set host_id = " . $_POST["host_id"] . " where id = " . $selected_items[$i]); api_graph_title_cache_update($selected_items[$i]); } } elseif ($_POST["drp_action"] == "6") { /* reapply suggested naming */ for ($i = 0; $i < count($selected_items); $i++) { api_reapply_suggested_graph_title($selected_items[$i]); api_graph_title_cache_update($selected_items[$i]); } } elseif ($_POST["drp_action"] == "7") { /* resize graphs */ for ($i = 0; $i < count($selected_items); $i++) { api_graph_resize($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]); } } header("Location: graphs.php"); exit; } /* setup some variables */ $graph_list = ""; $i = 0; /* loop through each of the graphs selected on the previous page and get more info about them */ while (list($var, $val) = each($_POST)) { if (ereg("^chk_([0-9]+)\$", $var, $matches)) { $graph_list .= "<li>" . db_fetch_cell("select title_cache from graph where id = " . $matches[1]) . "<br>"; $graph_array[$i] = $matches[1]; } $i++; } require_once CACTI_BASE_PATH . "/include/top_header.php"; html_start_box("<strong>" . $graph_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel_background"], "3", "center", ""); print "<form action='graphs.php' method='post'>\n"; if ($_POST["drp_action"] == "1") { /* delete */ $graphs = array(); /* find out which (if any) data sources are being used by this graph, so we can tell the user */ if (isset($graph_array)) { $data_sources = db_fetch_assoc("select distinct\n\t\t\t\tdata_source.id,\n\t\t\t\tdata_source.name_cache\n\t\t\t\tfrom data_source_item,data_source,graph_item\n\t\t\t\twhere graph_item.data_source_item_id=data_source_item.id\n\t\t\t\tand data_source_item.data_source_id=data_source.id\n\t\t\t\tand " . array_to_sql_or($graph_array, "graph_item.graph_id") . "\n\t\t\t\torder by data_source.name_cache"); } print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("Are you sure you want to delete the following graphs?") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t"; if (sizeof($data_sources) > 0) { print "<tr bgcolor='#" . $colors["form_alternate1"] . "'><td class='textArea'><p class='textArea'>" . _("The following data sources are in use by these graphs:") . "</p>\n"; foreach ($data_sources as $data_source) { print "<strong>" . $data_source["name_cache"] . "</strong><br>\n"; } print "<br>"; form_radio_button("delete_type", "1", "1", _("Leave the data sources untouched."), "1"); print "<br>"; form_radio_button("delete_type", "1", "2", _("Delete all <strong>data sources</strong> referenced by these graphs."), "1"); print "<br>"; print "</td></tr>"; } print "\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "2") { /* change graph template */ print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("Choose a graph template and click save to change the graph template for\n\t\t\t\t\tthe following graphs. Be aware that all warnings will be suppressed during the\n\t\t\t\t\tconversion, so graph data loss is possible.") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t<p><strong>" . _("New Graph Template:") . "</strong><br>"; form_dropdown("graph_template_id", db_fetch_assoc("select graph_templates.id,graph_templates.name from graph_templates"), "name", "id", "", "", "0"); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "3") { /* duplicate */ print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("When you click save, the following graphs will be duplicated. You can\n\t\t\t\t\toptionally change the title format for the new graphs.") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t<p><strong>" . _("Title Format:") . "</strong><br>"; form_text_box("title_format", "<graph_title> (1)", "", "255", "30", "text"); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "4") { /* graph -> graph template */ print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("When you click save, the following graphs will be converted into graph templates.\n\t\t\t\t\tYou can optionally change the title format for the new graph templates.") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t<p><strong>" . _("Title Format:") . "</strong><br>"; form_text_box("title_format", "<graph_title> " . _("Template"), "", "255", "30", "text"); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "5") { /* change device */ print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("Choose a new host for these graphs:") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t<p><strong>" . _("New Device:") . "</strong><br>"; form_dropdown("host_id", db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "name", "id", "", "", "0"); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "6") { /* reapply suggested naming to host */ print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("When you click save, the following graphs will have thier suggested naming convensions\n\t\t\t\t\trecalculated and applies to the graphs.") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "7") { /* reapply suggested naming to host */ print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>When you click save, the following graphs will be resized per your specifications.</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t<p><strong>Graph Height:</strong><br>"; form_text_box("graph_height", "", "", "255", "30", "text"); print "</p>\n\t\t\t\t\t<p><strong>Graph Width:</strong><br>"; form_text_box("graph_width", "", "", "255", "30", "text"); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t"; } elseif ($_POST["drp_action"] == "8") { /* place on tree */ $trees = db_fetch_assoc("select id,name from graph_tree order by name"); print "\t<tr>\n\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>" . _("When you click save, the following graphs will be placed under the branch selected\n\t\t\t\t\tbelow.") . "</p>\n\t\t\t\t\t<p>{$graph_list}</p>\n\t\t\t\t\t<p><strong>" . _("Destination Branch:") . "</strong><br>"; html_tree_dropdown_draw($matches[1], "tree_item_id", "0"); print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\n\t\t\t<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n\n\t\t\t"; } if (!isset($graph_array)) { print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>" . _("You must select at least one graph.") . "</span></td></tr>\n"; $save_html = ""; } else { $save_html = "<input type='image' src='" . html_get_theme_images_path("button_yes.gif") . "' alt='" . _("Save") . "' align='absmiddle'>"; } print "\t<tr>\n\t\t\t<td align='right' bgcolor='#" . $colors["buttonbar_background"] . "'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($graph_array) ? serialize($graph_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\n\t\t\t\t<a href='graphs.php'><img src='" . html_get_theme_images_path("button_no.gif") . "' alt='" . _("Cancel") . "' align='absmiddle' border='0'></a>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t"; html_end_box(); require_once CACTI_BASE_PATH . "/include/bottom_footer.php"; }
function _graph_tree_item_field__parent_item_id($graph_tree_id, $field_name, $field_value = "", $field_id = 0) { require_once(CACTI_BASE_PATH . "/lib/sys/html_form.php"); require_once(CACTI_BASE_PATH . "/lib/sys/html_tree.php"); require_once(CACTI_BASE_PATH . "/lib/graph_tree/graph_tree_info.php"); ?> <tr class="<?php echo field_get_row_style();?>"> <td width="50%" class="field-row"> <span class="textEditTitle"><?php echo _("Parent Branch");?></span><br> <?php echo _("Choose a parent branch for this item which controls where on the tree this branch lies.");?> </td> <td class="field-row" colspan="2"> <?php html_tree_dropdown_draw($graph_tree_id, $field_name, $field_value);?> </td> </tr> <?php }