Download | Plain Text | No Line Numbers


  1. --- host.php.orig 2006-10-09 05:06:01.000000000 +0200
  2. +++ host.php 2006-12-05 14:55:29.000000000 +0100
  3. @@ -41,7 +41,8 @@
  4. 2 => "Enable",
  5. 3 => "Disable",
  6. 4 => "Change SNMP Options",
  7. - 5 => "Clear Statistics"
  8. + 5 => "Clear Statistics",
  9. + 6 => "Reapply Host Template"
  10. );
  11.  
  12. /* set default action */
  13. @@ -270,6 +271,32 @@
  14.  
  15. api_device_remove($selected_items[$i]);
  16. }
  17. + }elseif ($_POST["drp_action"] == "6") { /* Reapply Host Template */
  18. + for ($i=0;($i<count($selected_items));$i++) {
  19. + /* ================= input validation ================= */
  20. + input_validate_input_number($selected_items[$i]);
  21. + /* ==================================================== */
  22. +
  23. + $host_template_id = db_fetch_cell("select host_template_id from host where id=$selected_items[$i]");
  24. + $snmp_queries = db_fetch_assoc("select snmp_query_id from host_template_snmp_query where host_template_id=$host_template_id");
  25. +
  26. + if (sizeof($snmp_queries) > 0) {
  27. + foreach ($snmp_queries as $snmp_query) {
  28. + 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 . ")");
  29. +
  30. + /* recache snmp data */
  31. + run_data_query($selected_items[$i], $snmp_query["snmp_query_id"]);
  32. + }
  33. + }
  34. +
  35. + $graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id=$host_template_id");
  36. +
  37. + if (sizeof($graph_templates) > 0) {
  38. + foreach ($graph_templates as $graph_template) {
  39. + db_execute("replace into host_graph (host_id,graph_template_id) values ($selected_items[$i]," . $graph_template["graph_template_id"] . ")");
  40. + }
  41. + }
  42. + }
  43. }elseif (ereg("^tr_([0-9]+)$", $_POST["drp_action"], $matches)) { /* place on tree */
  44. for ($i=0;($i<count($selected_items));$i++) {
  45. /* ================= input validation ================= */
  46. @@ -363,6 +390,13 @@
  47. <p>$host_list</p>
  48. </td>
  49. </tr>";
  50. + }elseif ($_POST["drp_action"] == "6") { /* Reapply Host Template */
  51. + print " <tr>
  52. + <td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
  53. + <p>To reapply Host Template for the following devices, press the \"yes\" button below.</p>
  54. + <p>$host_list</p>
  55. + </td>
  56. + </tr>";
  57. }elseif ($_POST["drp_action"] == "1") { /* delete */
  58. print " <tr>
  59. <td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
  60.