From f581cc13c156d8e4871efad0a3e67b6ed9515fdd Mon Sep 17 00:00:00 2001
From: mdtrooper <tres.14159@gmail.com>
Date: Wed, 25 Sep 2013 07:28:29 +0000
Subject: [PATCH] 2013-09-25 Miguel de Dios <miguel.dedios@artica.es>

	* godmode/modules/manage_network_components_form_common.php,
	godmode/modules/manage_network_components_form.php: fixed the
	javascript to configure the form of snmp.

	* godmode/agentes/module_manager_editor.php,
	godmode/agentes/configurar_agente.php,
	godmode/agentes/module_manager_editor_common.php: fixed the
	"module_macros" when it is fail when is not set for example.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8806 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                      | 11 +++++++++++
 .../godmode/agentes/configurar_agente.php      |  3 ++-
 .../godmode/agentes/module_manager_editor.php  |  5 ++++-
 .../agentes/module_manager_editor_common.php   | 18 +++++++++++-------
 .../modules/manage_network_components_form.php | 14 +++++++++++---
 .../manage_network_components_form_common.php  |  2 +-
 6 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 16464738c9..09540f1461 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,14 @@
+2013-09-25 Miguel de Dios <miguel.dedios@artica.es>
+	
+	* godmode/modules/manage_network_components_form_common.php,
+	godmode/modules/manage_network_components_form.php: fixed the
+	javascript to configure the form of snmp.
+	
+	* godmode/agentes/module_manager_editor.php,
+	godmode/agentes/configurar_agente.php,
+	godmode/agentes/module_manager_editor_common.php: fixed the
+	"module_macros" when it is fail when is not set for example.
+
 2013-09-24  Sergio Martin <sergio.martin@artica.es>
 
 	* godmode/reporting/reporting_builder.item_editor.php: Added
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index dcd95f3714..c45e234f2b 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -1089,7 +1089,8 @@ if ($create_module) {
 		$id_agent_module = false;
 	}
 	else {
-		$id_agent_module = modules_create_agent_module ($id_agente, $name, $values, false, $id_tag);
+		$id_agent_module = modules_create_agent_module (
+			$id_agente, $name, $values, false, $id_tag);
 	}
 	
 	if (is_error($id_agent_module)) {
diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php
index 7e9102e720..bf399c6a80 100644
--- a/pandora_console/godmode/agentes/module_manager_editor.php
+++ b/pandora_console/godmode/agentes/module_manager_editor.php
@@ -231,7 +231,10 @@ if ($id_agent_module) {
 		$wday = '*';
 	}
 	
-	$module_macros = json_decode(base64_decode($module['module_macros']));
+	$module_macros = null;
+	if (isset($module['module_macros'])) {
+		$module_macros = json_decode(base64_decode($module['module_macros']));
+	}
 }
 else {
 	if (!isset ($moduletype)) {
diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php
index 9bd0d5be06..b08dbe9624 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_common.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_common.php
@@ -483,13 +483,17 @@ $table_macros->style[5] = 'width: 10px';
 $table_macros->colspan = array ();
 
 $macro_count = 0;
-foreach ($module_macros as $macro_name => $macro_value) {
-	$table_macros->data[$macro_count][0] = __('Name');
-	$table_macros->data[$macro_count][1] = html_print_input_text ('module_macro_names[]', $macro_name, '', 50, 60, true);
-	$table_macros->data[$macro_count][2] = __('Value');
-	$table_macros->data[$macro_count][3] = html_print_input_text ('module_macro_values[]', $macro_value, '', 50, 60, true);
-	$table_macros->data[$macro_count][4] = '<a href="javascript: delete_macro(' . $macro_count . ');">' . html_print_image('images/cross.png', true) . '</a>';
-	$macro_count++;
+if (isset($module_macros)) {
+	if (is_array($module_macros)) {
+		foreach ($module_macros as $macro_name => $macro_value) {
+			$table_macros->data[$macro_count][0] = __('Name');
+			$table_macros->data[$macro_count][1] = html_print_input_text ('module_macro_names[]', $macro_name, '', 50, 60, true);
+			$table_macros->data[$macro_count][2] = __('Value');
+			$table_macros->data[$macro_count][3] = html_print_input_text ('module_macro_values[]', $macro_value, '', 50, 60, true);
+			$table_macros->data[$macro_count][4] = '<a href="javascript: delete_macro(' . $macro_count . ');">' . html_print_image('images/cross.png', true) . '</a>';
+			$macro_count++;
+		}
+	}
 }
 $table_macros->data[$macro_count][0] = '<span>'.__('Add module macro').'</span> <a href="javascript:add_macro();">'.html_print_image('images/add.png',true).'</a>';
 $table_macros->colspan[$macro_count][0] = 5;
diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php
index bddfcb421d..763c68fed5 100644
--- a/pandora_console/godmode/modules/manage_network_components_form.php
+++ b/pandora_console/godmode/modules/manage_network_components_form.php
@@ -249,7 +249,7 @@ function type_change () {
 		document.component.tcp_rcv.disabled=true;
 		document.component.tcp_port.style.background="#ddd";
 		document.component.tcp_port.disabled=true;
-
+		
 		document.component.snmp_version.style.background="#ddd";
 		document.component.snmp_version.disabled=true;
 		document.component.snmp3_auth_user.style.background="#ddd";
@@ -279,7 +279,7 @@ function type_change () {
 		document.component.tcp_rcv.disabled=true;
 		document.component.tcp_port.style.background="#fff";
 		document.component.tcp_port.disabled=false;
-
+		
 		document.component.snmp_version.style.background="#fff";
 		document.component.snmp_version.disabled=false;
 		document.component.snmp3_auth_user.style.background="#fff";
@@ -294,6 +294,8 @@ function type_change () {
 		document.component.snmp3_auth_method.disabled=false;
 		document.component.snmp3_security_level.style.background="#fff";
 		document.component.snmp3_security_level.disabled=false;
+		
+		$("#snmp_version" ).trigger("change");
 	}
 	// type 6-7 - ICMP
 	if ((document.component.type.value == 6) || (document.component.type.value == 7)) {
@@ -398,6 +400,7 @@ $(document).ready (function () {
 			}
 		});
 	});
+	
 	$("#left").click (function () {
 		jQuery.each($("select[name='id_tag_selected[]'] option:selected"), function (key, value) {
 				tag_name = $(value).html();
@@ -412,16 +415,19 @@ $(document).ready (function () {
 				}
 		});
 	});
+	
 	$("#submit-crt").click(function () {
 		$('#id_tag_selected option').map(function() {
 			$(this).attr('selected','selected');
 		});
 	});
+	
 	$("#submit-upd").click(function () {
 		$('#id_tag_selected option').map(function() {
 			$(this).attr('selected','selected');
 		});
 	});
+	
 	if ($("#snmp_version").value == "3") {
 		$("input[name=snmp3_auth_user]").css({backgroundColor: '#fff'});
 		$("input[name=snmp3_auth_user]").removeAttr('disabled');
@@ -525,7 +531,7 @@ $(document).ready (function () {
 	});
 	
 	$("#type"). change(function () {
-		if ($("#snmp_version").value == "3") {
+		if ($("#snmp_version").val() == "3") {
 			$("input[name=snmp3_auth_user]").css({backgroundColor: '#fff'});
 			$("input[name=snmp3_auth_user]").removeAttr('disabled');
 			
@@ -575,6 +581,8 @@ $(document).ready (function () {
 			$("input[name=snmp_community]").removeAttr('disabled');
 		}
 	});
+	
+	$("#snmp_version" ).trigger("change");
 });
 
 <?php
diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php
index cd781784f0..0501a445b4 100644
--- a/pandora_console/godmode/modules/manage_network_components_form_common.php
+++ b/pandora_console/godmode/modules/manage_network_components_form_common.php
@@ -71,7 +71,7 @@ $sql = sprintf ('SELECT id_tipo, descripcion
 	ORDER BY descripcion',
 	implode (',', $categories));
 $table->data[1][1] = html_print_select_from_sql ($sql, 'type',
-	$type, '', '', '', true,
+	$type, 'javascript: type_change();', '', '', true,
 	false, false, false, true, false, false, false, 0);
 
 // Store the relation between id and name of the types on a hidden field