justruss wrote:Well the good new is you're running into the same issue I described, the bad news is you should have been all set by commenting out that bit I referred to earlier.
Can you paste the first 100 lines or so from the function form_actions() inside /usr/share/cacti/site/graphs.php?
Sure. Anything that may help at this point. Here's a chunk:
---
/* ------------------------
The "actions" function
------------------------ */
function form_actions() {
global $colors, $graph_actions;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post('drp_action'));
/* ==================================================== */
/* 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 */
if (!isset($_POST["delete_type"])) { $_POST["delete_type"] = 1; }
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
}
switch ($_POST["delete_type"]) {
case '2': /* delete all data sources referenced by this graph */
$data_sources = array_rekey(db_fetch_assoc("SELECT data_template_data.local_data_id
FROM (data_template_rrd, data_template_data, graph_templates_item)
WHERE graph_templates_item.task_item_id=data_template_rrd.id
AND data_template_rrd.local_data_id=data_template_data.local_data_id
AND " . array_to_sql_or($selected_items, "graph_templates_item.local_graph_id") . "
AND data_template_data.local_data_id > 0"), "local_data_id", "local_data_id");
if (sizeof($data_sources)) {
api_data_source_remove_multi($data_sources);
api_plugin_hook_function('data_source_remove', $data_sources);
}
break;
}
api_graph_remove_multi($selected_items);
api_plugin_hook_function('graphs_remove', $selected_items);
}elseif ($_POST["drp_action"] == "2") { /* change graph template */
input_validate_input_number(get_request_var_post("graph_template_id"));
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($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++) {
/* ================= input validation ================= */
input_validate_input_number($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++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
graph_to_graph_template($selected_items[$i], $_POST["title_format"]);
}
}elseif (preg_match("/^tr_([0-9]+)$/", $_POST["drp_action"], $matches)) { /* place on tree */
input_validate_input_number(get_request_var_post("tree_id"));
input_validate_input_number(get_request_var_post("tree_item_id"));
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($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 */
input_validate_input_number(get_request_var_post("host_id"));
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
db_execute("update graph_local set host_id=" . $_POST["host_id"] . " where id=" . $selected_items[$i]);
update_graph_title_cache($selected_items[$i]);
}
}elseif ($_POST["drp_action"] == "6") { /* reapply suggested naming */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_reapply_suggested_graph_title($selected_items[$i]);
update_graph_title_cache($selected_items[$i]);
}
}elseif ($_POST["drp_action"] == "7") { /* resize graphs */
input_validate_input_number(get_request_var_post("graph_width"));
input_validate_input_number(get_request_var_post("graph_height"));
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
}
} else {
api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
}
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 (preg_match("/^chk_([0-9]+)$/", $var, $matches)) {
/* ================= input validation ================= */
input_validate_input_number($matches[1]);
/* ==================================================== */
$graph_list .= "<li>" . get_graph_title($matches[1]) . "</li>";
$graph_array[$i] = $matches[1];
$i++;
}
}
include_once("./include/top_header.php");
/* add a list of tree names to the actions dropdown */
add_tree_names_to_actions_array();
html_start_box("<strong>" . $graph_actions{$_POST["drp_action"]} . "</strong>", "60%", $colors["header_panel"], "3", "center", "");
print "<form action='graphs.php' method='post'>\n";
if (isset($graph_array) && sizeof($graph_array)) {
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) && sizeof($graph_array)) {
$data_sources = db_fetch_assoc("select
data_template_data.local_data_id,
data_template_data.name_cache
from (data_template_rrd,data_template_data,graph_templates_item)
where graph_templates_item.task_item_id=data_template_rrd.id
and data_template_rrd.local_data_id=data_template_data.local_data_id
and " . array_to_sql_or($graph_array, "graph_templates_item.local_graph_id") . "
and data_template_data.local_data_id > 0
group by data_template_data.local_data_id
order by data_template_data.name_cache");
}
print " <tr>
<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
<p>When you click \"Continue\", the following Graph(s) will be deleted. Please note, Data Source(s) should be deleted only if they are only used by these Graph(s)
and not others.</p>
<p><ul>$graph_list</ul></p>";
if (isset($data_sources) && sizeof($data_sources)) {
print "<tr bgcolor='#" . $colors["form_alternate1"] . "'><td class='textArea'><p class='textArea'>The following Data Source(s) are in use by these Graph(s):</p>\n";
print "<ul>";
foreach ($data_sources as $data_source) {
print "<li><strong>" . $data_source["name_cache"] . "</strong></li>\n";
}
print "</ul>";
print "<br>";
form_radio_button("delete_type", "1", "1", "Leave the Data Source(s) untouched.", "1"); print "<br>";
form_radio_button("delete_type", "1", "2", "Delete all <strong>Data Source(s)</strong> referenced by these Graph(s).", "1"); print "<br>";
print "</td></tr>";
}
print "
</td>
</tr>\n
";
$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Graph(s)'>";
}elseif ($_POST["drp_action"] == "2") { /* change graph template */