diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9ca71f08bf..699382294c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2008-10-24 Esteban Sanchez + + * operation/snmpconsole/snmp_alert.php: Fixed an error that doesn't + allow to show some fields when editing an alert. It's done using + javascript, but a PHP version might be better. Style correction. + + * include/functions_db.php: Added get_agent_with_ip(). + + * operation/snmpconsole/snmp_view.php: Use get_agent_with_ip() since + using get_db_row() is not enough for agents with many addresses. + 2008-10-23 Esteban Sanchez * operation/agentes/estado_agente.php: Use print_select() to show the diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index f02f7846a3..058ab82845 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1273,6 +1273,22 @@ function give_agent_address ($id_agent) { return (string) get_db_value ('direccion', 'tagente', 'id_agente', $id_agent); } +/** + * Get the agent that matches an IP address + * + * @param $ip_address IP address to get the agents. + * + * @return The agent that has the IP address given. False if none were found. + */ +function get_agent_with_ip ($ip_address) { + $sql = sprintf ('SELECT tagente.* + FROM tagente, taddress, taddress_agent + WHERE tagente.id_agente = taddress_agent.id_agent + AND taddress_agent.id_a = taddress.id_a + AND ip = "%s"', $ip_address); + return get_db_row_sql ($sql); +} + /** * Get IP address of an agent from address list * diff --git a/pandora_console/operation/snmpconsole/snmp_alert.php b/pandora_console/operation/snmpconsole/snmp_alert.php index 0d63480694..72ae7057e1 100644 --- a/pandora_console/operation/snmpconsole/snmp_alert.php +++ b/pandora_console/operation/snmpconsole/snmp_alert.php @@ -133,8 +133,9 @@ if ((isset ($_GET["update_alert"])) && ($_GET["update_alert"] != -1)) { } // Alert form -if (isset ($_GET["update_alert"])) { //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated - if ($id_as > 1) { +if (isset ($_GET["update_alert"])) { + //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated + if ($id_as) { echo "

Pandora SNMP > ".__('Update alert')."

"; } else { echo "

Pandora SNMP > ".__('Create alert')."

"; @@ -376,8 +377,7 @@ function time_changed () { } } -function trigger_changed () { - var trigger = this.value; +function trigger_changed (trigger) { if (trigger == 0) { $('#tr-custom_value').fadeOut ('fast'); $('#tr-source_ip').fadeOut ('fast'); @@ -400,6 +400,13 @@ function trigger_changed () { $(document).ready (function () { $('#time_threshold').change (time_changed); - $('#alert_trigger').change (trigger_changed); + $('#alert_trigger').change (function () { + trigger_changed (this.value) + }); + }); diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index ed0081e16d..0c1a0f3795 100644 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -174,8 +174,8 @@ foreach ($traps as $trap) { $data[0] = ''; } - // Agent matching - $agent = get_db_row ('tagente', 'direccion', $trap['source']); + // Agent matching source address + $agent = get_agent_with_ip ($trap['source']); if ($agent !== false && ! give_acl ($config["id_user"], $agent["id_grupo"], "AR")) { //Agent found, no rights continue; @@ -189,7 +189,7 @@ foreach ($traps as $trap) { } else { //Agent found $data[1] = ''; - $data[1] .= ''.$agent["nombre"].''; + $data[1] .= ''.$agent["nombre"].''; } //OID