Download | Plain Text | Line Numbers
--- host.php.orig 2006-10-09 05:06:01.000000000 +0200
+++ host.php 2006-12-05 14:55:29.000000000 +0100
@@ -41,7 +41,8 @@
2 => "Enable",
3 => "Disable",
4 => "Change SNMP Options",
- 5 => "Clear Statistics"
+ 5 => "Clear Statistics",
+ 6 => "Reapply Host Template"
);
/* set default action */
@@ -270,6 +271,32 @@
api_device_remove($selected_items[$i]);
}
+ }elseif ($_POST["drp_action"] == "6") { /* Reapply Host Template */
+ for ($i=0;($i<count($selected_items));$i++) {
+ /* ================= input validation ================= */
+ input_validate_input_number($selected_items[$i]);
+ /* ==================================================== */
+
+ $host_template_id = db_fetch_cell("select host_template_id from host where id=$selected_items[$i]");
+ $snmp_queries = db_fetch_assoc("select snmp_query_id from host_template_snmp_query where host_template_id=$host_template_id");
+
+ if (sizeof($snmp_queries) > 0) {
+ foreach ($snmp_queries as $snmp_query) {
+ db_execute("replace into host_snmp_query (host_id,snmp_query_id,reindex_method) values ($selected_items[$i]," . $snmp_query["snmp_query_id"] . "," . DATA_QUERY_AUTOINDEX_BACKWARDS_UPTIME . ")");
+
+ /* recache snmp data */
+ run_data_query($selected_items[$i], $snmp_query["snmp_query_id"]);
+ }
+ }
+
+ $graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id=$host_template_id");
+
+ if (sizeof($graph_templates) > 0) {
+ foreach ($graph_templates as $graph_template) {
+ db_execute("replace into host_graph (host_id,graph_template_id) values ($selected_items[$i]," . $graph_template["graph_template_id"] . ")");
+ }
+ }
+ }
}elseif (ereg("^tr_([0-9]+)$", $_POST["drp_action"], $matches)) { /* place on tree */
for ($i=0;($i<count($selected_items));$i++) {
/* ================= input validation ================= */
@@ -363,6 +390,13 @@
<p>$host_list</p>
</td>
</tr>";
+ }elseif ($_POST["drp_action"] == "6") { /* Reapply Host Template */
+ print " <tr>
+ <td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
+ <p>To reapply Host Template for the following devices, press the \"yes\" button below.</p>
+ <p>$host_list</p>
+ </td>
+ </tr>";
}elseif ($_POST["drp_action"] == "1") { /* delete */
print " <tr>
<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>