From 0fc33f3fa265614326e7bdefd3161eb5b96547e1 Mon Sep 17 00:00:00 2001
From: danielmaya <daniel.maya@artica.es>
Date: Fri, 23 Feb 2018 14:38:26 +0100
Subject: [PATCH 01/17] Fixed module filter in view events

---
 pandora_console/operation/events/events.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php
index a7e6523c7e..9564e87b5e 100644
--- a/pandora_console/operation/events/events.php
+++ b/pandora_console/operation/events/events.php
@@ -275,7 +275,7 @@ if ($id_agent != 0) {
 }
 
 $text_module = (string) get_parameter('module_search', '');
-$id_agent_module = get_parameter('module_search_hidden', 0);
+$id_agent_module = get_parameter('module_search_hidden', get_parameter('id_agent_module',0));
 if ($id_agent_module != 0) {
 	$text_module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agent_module);
 	if ($text_module == false) {

From 9a4ea419420db3732596b81a11b53c35021f5117 Mon Sep 17 00:00:00 2001
From: enriquecd <enrique.camargo@artica.com>
Date: Wed, 7 Mar 2018 16:18:35 +0100
Subject: [PATCH 02/17] Add search bar to cluster agent aggregator - #1866

---
 .../operation/agentes/ver_agente.php          | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php
index b94a7733db..6058b90724 100644
--- a/pandora_console/operation/agentes/ver_agente.php
+++ b/pandora_console/operation/agentes/ver_agente.php
@@ -44,12 +44,16 @@ if (is_ajax ()) {
 	$get_agentmodule_status_tooltip = (bool) get_parameter ("get_agentmodule_status_tooltip");
 	$get_group_status_tooltip = (bool) get_parameter ("get_group_status_tooltip");
 	$get_agent_id = (bool) get_parameter ("get_agent_id");
+	$cluster_mode = (bool) get_parameter ("cluster_mode",0);
+	$agent_alias = get_parameter('alias', '');
+	$agents_inserted = get_parameter('agents_inserted', array());
 	$id_group = (int) get_parameter('id_group');
 	if ($get_agents_group_json) {
 		$id_group = (int) get_parameter('id_group');
 		$recursion = get_parameter ('recursion');
 		$id_os = get_parameter('id_os', '');
 		$agent_name = get_parameter('name', '');
+		
 		$privilege = (string) get_parameter ('privilege', "AR");
 		// Is is possible add keys prefix to avoid auto sorting in js object conversion
 		$keys_prefix = (string) get_parameter ('keys_prefix', '');
@@ -75,6 +79,8 @@ if (is_ajax ()) {
 			$filter['id_os'] = $id_os;
 		if (!empty($agent_name))
 			$filter['nombre'] = '%' . $agent_name . '%';
+		if (!empty($agent_alias))
+			$filter['alias'] = '%' . $agent_alias . '%';
 		
 		switch ($status_agents) {
 			case AGENT_STATUS_NORMAL:
@@ -98,6 +104,43 @@ if (is_ajax ()) {
 		}
 		$filter['order'] = "alias ASC";
 		
+		if($cluster_mode){
+			
+			$agent_id_os = db_get_all_rows_sql('select id_os from tconfig_os where id_os != 21');
+			
+			foreach ($agent_id_os as $key => $value) {
+				$agent_id_os_array[] = $agent_id_os[$key]['id_os'];
+			}
+			
+			$filter['id_os'] = $agent_id_os_array;
+			
+			if($agents_inserted[0] != ''){
+			
+				$agents_id_list = '';
+				
+				foreach($agents_inserted as $elem) {
+
+				    if ($elem === end($agents_inserted)) {
+				      $agents_id_list .= $elem;
+				    }
+						else{
+							$agents_id_list .= $elem.',';
+						}
+
+				}
+				
+				$agent_id_agente = db_get_all_rows_sql('select id_agente from tagente where id_agente not in ('.$agents_id_list.')');
+				
+				foreach ($agent_id_agente as $key => $value) {
+					$agent_id_agente_array[] = $agent_id_agente[$key]['id_agente'];
+				}
+				
+				$filter['id_agente'] = $agent_id_agente_array;
+				
+			}
+			
+		}
+		
 		// Build fields
 		$fields = array('id_agente', 'alias');
 

From 97bcaec72050c8926d42dff895dc1ce59472fc75 Mon Sep 17 00:00:00 2001
From: enriquecd <enrique.camargo@artica.com>
Date: Thu, 8 Mar 2018 11:58:31 +0100
Subject: [PATCH 03/17] Not blink separator dots for digital clocks - #2026

---
 pandora_console/include/graphs/pandora.d3.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js
index 98d4a54557..300ff0b665 100644
--- a/pandora_console/include/graphs/pandora.d3.js
+++ b/pandora_console/include/graphs/pandora.d3.js
@@ -2334,7 +2334,7 @@ var digitPattern = [
   digit.select("path:nth-child(5)").classed("lit", function(d) { return digitPattern[4][d]; });
   digit.select("path:nth-child(6)").classed("lit", function(d) { return digitPattern[5][d]; });
   digit.select("path:nth-child(7)").classed("lit", function(d) { return digitPattern[6][d]; });
-  separator.classed("lit", seconds & 1);
+  separator.classed("lit", seconds);
 
   setTimeout(tick, 1000 - now % 1000);
 })();

From 753d10920ab6e28e7794d68365b2e9f06953f80f Mon Sep 17 00:00:00 2001
From: enriquecd <enrique.camargo@artica.com>
Date: Tue, 13 Mar 2018 12:46:27 +0100
Subject: [PATCH 04/17] Hide password custom fields data in agent custom fileds
 section - #2030

---
 .../operation/agentes/custom_fields.php       | 21 +++++++++++--------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/pandora_console/operation/agentes/custom_fields.php b/pandora_console/operation/agentes/custom_fields.php
index b9f33aa672..607ab06360 100644
--- a/pandora_console/operation/agentes/custom_fields.php
+++ b/pandora_console/operation/agentes/custom_fields.php
@@ -78,19 +78,22 @@ else {
 			$data[1] = html_print_image('images/delete.png', true);
 		}
 		
-		$custom_value = db_get_value_filter('description',
-			'tagent_custom_data', array(
-				'id_field' => $field['id_field'],
-				'id_agent' => $id_agente));
-		
-		if ($custom_value === false || $custom_value == '') {
-			$custom_value = '<i>-'.__('empty').'-</i>';
+		$custom_value = db_get_all_rows_sql("select tagent_custom_data.description,tagent_custom_fields.is_password_type from tagent_custom_fields 
+		INNER JOIN tagent_custom_data ON tagent_custom_fields.id_field = tagent_custom_data.id_field where tagent_custom_fields.id_field = ".$field['id_field']." and tagent_custom_data.id_agent = ".$id_agente);
+				
+		if ($custom_value[0]['description'] === false || $custom_value[0]['description'] == '') {
+			$custom_value[0]['description'] = '<i>-'.__('empty').'-</i>';
 		}
 		else {
-			$custom_value = ui_bbcode_to_html($custom_value);
+			$custom_value[0]['description'] = ui_bbcode_to_html($custom_value[0]['description']);
 		}
 		
-		$data[2] = $custom_value;
+		if($custom_value[0]['is_password_type']){
+			$data[2] = '&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;';
+		}
+		else{
+			$data[2] = $custom_value[0]['description'];	
+		}
 		
 		array_push ($table->data, $data);
 	}

From d38df88c79656117162e131628a0b7b1b73821ea Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Tue, 13 Mar 2018 19:07:31 +0100
Subject: [PATCH 05/17] [Pie charts] Adding more space in legend

---
 pandora_console/include/graphs/functions_pchart.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php
index fcbd67f00a..0114d36e32 100644
--- a/pandora_console/include/graphs/functions_pchart.php
+++ b/pandora_console/include/graphs/functions_pchart.php
@@ -522,7 +522,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
 	
 	if ($legend_position != 'hidden') {
 		// This is a hardcore adjustment to match most of the graphs, please don't alter
-		$legend_with_aprox = 32 + (4.5 * $max_chars);
+		$legend_with_aprox = 32 + (9.5 * $max_chars);
 		
 		$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10)); 
 	}

From 690ad81a6265f31376f2a651d3b23fe051bc1354 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Wed, 14 Mar 2018 13:31:54 +0100
Subject: [PATCH 06/17] [Visual Console] Changed simple select by group select
 in restricted group advanced fieldin static graph

---
 .../include/functions_visual_map_editor.php          | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php
index c9e8074dc1..b5f39f80d6 100755
--- a/pandora_console/include/functions_visual_map_editor.php
+++ b/pandora_console/include/functions_visual_map_editor.php
@@ -735,7 +735,17 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
 				'icon', 'label', 'datos');
 			$form_items_advance['element_group_row']['html'] = '<td align="left">'.
 				__('Restrict access to group') . '</td>' .
-				'<td align="left">' . html_print_select($user_groups, 'element_group', '', '', '', 0, true) . 
+				'<td align="left">' .
+				html_print_select_groups(
+					$config['id_user'],
+					"VR",
+					true,
+					'element_group',
+					__('All'),
+					'',
+					'',
+					0,
+					true) .
 				ui_print_help_tip (
 					__("If selected, restrict visualization of this item in the visual console to users who have access to selected group. This is also used on calculating child visual consoles."), true) . 
 				'</td>';

From a8cb366508d944d6ff0ba8b64c64bb80ad64a5f1 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Wed, 14 Mar 2018 17:24:34 +0100
Subject: [PATCH 07/17] [Alerts view] Fixed validation in alerts view

---
 pandora_console/include/functions_ui.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php
index 751b1bf34e..caffcad739 100755
--- a/pandora_console/include/functions_ui.php
+++ b/pandora_console/include/functions_ui.php
@@ -961,9 +961,15 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f
 	if (!defined('METACONSOLE')) {
 		if (check_acl ($config["id_user"], $id_group, "LW") || check_acl ($config["id_user"], $id_group, "LM")) {
 			$data[$index['validate']] = '';
-			
-			
-			$data[$index['validate']] .= html_print_checkbox ("validate[]", $alert["id"], false, true);
+
+			$data[$index['validate']] .= html_print_checkbox (
+				"validate[]",
+				$alert["id"],
+				false,
+				true,
+				false,
+				'',
+				true);
 		}
 	}
 	

From 1001240cf460375f22dd1adb92729bda3626a485 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Thu, 15 Mar 2018 16:03:46 +0100
Subject: [PATCH 08/17] [SNMP] Fixed translation of custom mibs, added custom
 description data and change style of OID details

---
 .../extensions/realtime_graphs.php            |  2 +-
 .../agentes/module_manager_editor_network.php |  2 +-
 .../include/functions_snmp_browser.php        | 41 +++++++++++--------
 .../javascript/pandora_snmp_browser.js        |  3 +-
 pandora_console/include/styles/pandora.css    |  9 +++-
 5 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/pandora_console/extensions/realtime_graphs.php b/pandora_console/extensions/realtime_graphs.php
index b4fade177d..a218d59710 100644
--- a/pandora_console/extensions/realtime_graphs.php
+++ b/pandora_console/extensions/realtime_graphs.php
@@ -122,7 +122,7 @@ function pandora_realtime_graphs () {
 	echo '</form>';
 	
 	// Define a custom action to save the OID selected in the SNMP browser to the form
-	html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/hand_point.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
+	html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
 	html_print_input_hidden ('incremental_base', '0');
 
 	echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>';
diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php
index 915d1b542a..557b17f388 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_network.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_network.php
@@ -27,7 +27,7 @@ html_print_input_hidden ('ajax_url', ui_get_full_url("ajax.php"), false);
 html_print_input_hidden ('search_matches_translation', __("Search matches"), false);
 
 // Define a custom action to save the OID selected in the SNMP browser to the form
-html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/hand_point.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
+html_print_input_hidden ('custom_action', urlencode (base64_encode('&nbsp;<a href="javascript:setOID()"><img src="' . ui_get_full_url("images") . '/input_filter.disabled.png" title="' . __("Use this OID") . '" style="vertical-align: middle;"></img></a>')), false);
 
 $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
 
diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php
index 390d6ec151..f101faee0f 100644
--- a/pandora_console/include/functions_snmp_browser.php
+++ b/pandora_console/include/functions_snmp_browser.php
@@ -383,7 +383,7 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
 		else {
 			$snmptranslate_bin = $config['snmptranslate'];
 		}
-		exec ($snmptranslate_bin . " -Td " .  escapeshellarg($oid),
+		exec ($snmptranslate_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . " -Td " .  escapeshellarg($oid),
 			$translate_output);
 		foreach ($translate_output as $line) {
 			if (preg_match ('/SYNTAX\s+(.*)/', $line, $matches) == 1) {
@@ -399,13 +399,18 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
 				$oid_data['display_hint'] = $matches[1];
 			}
 		}
-		
-		// Parse the description
-		$translate_output = implode ('', $translate_output);
-		if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) {
-			$oid_data['description'] = $matches[1];
+
+		// Parse the description. First search for it in custom values
+		$custom_data = db_get_row('ttrap_custom_values', 'oid', $oid);
+		if ($custom_data === false) {
+			$translate_output = implode ('', $translate_output);
+			if (preg_match ('/DESCRIPTION\s+\"(.*)\"/', $translate_output, $matches) == 1) {
+				$oid_data['description'] = $matches[1];
+			}
+		} else {
+			$oid_data['description'] = $custom_data['description'];
 		}
-		
+
 		$full_value = explode (':', trim ($full_oid[1]));
 		if (! isset ($full_value[1])) {
 			$oid_data['value'] = trim ($full_oid[1]);
@@ -482,26 +487,26 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '',
 		$table->data[$i][1] = $oid['status'];
 		$i++;
 	}
-	
+
 	$closer = '<a href="javascript:" onClick="hideOIDData();">';
 	$closer .= html_print_image ("images/blade.png", true, array ("title" => __('Close'), "style" => 'vertical-align: middle;'), false);
 	$closer .= '</a>';
-	
-	$table->head[0] = $closer;
-	$table->head[1] = __('OID Information');
-	
+
 	// Add a span for custom actions
 	if ($custom_action != '') {
-		$output .= '<span id="snmp_custom_action">' . $closer . $custom_action . '</span>';
+		$table->head[0] = '<span id="snmp_custom_action">' . $closer . $custom_action . '</span>';
+	} else {
+		$table->head[0] = $closer;
 	}
-	
+
+	$table->head[1] = __('OID Information');
 	$output .= html_print_table($table, true);
-	
+
 	$url = "index.php?" .
 		"sec=gmodules&" .
 		"sec2=godmode/modules/manage_network_components";
 	
-	$output .= '<form style="text-align: center;" method="post" action="' . $url . '">';
+	$output .= '<form style="text-align: center; margin: 10px" method="post" action="' . $url . '">';
 	$output .= html_print_input_hidden('create_network_from_snmp_browser', 1, true);
 	$output .= html_print_input_hidden('id_component_type', 2, true);
 	$output .= html_print_input_hidden('type', 17, true);
@@ -519,7 +524,7 @@ function snmp_browser_print_oid ($oid = array(), $custom_action = '',
 	$output .= html_print_input_hidden('snmp_community', $community, true);
 	$output .= html_print_input_hidden('snmp_version', $snmp_version, true);
 	$output .= html_print_submit_button(__('Create network component'),
-		'', false, '', true);
+		'', false, 'class="sub add"', true);
 	$output .= '</form>';
 	
 	if ($return) {
@@ -672,7 +677,7 @@ function snmp_browser_print_container ($return = false, $width = '100%', $height
 	$output .=     '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>';
 	$output .=     '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">' . html_print_image ("images/spinner.gif", true) . '</div>';
 	$output .=     '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
-	$output .=     '<div id="snmp_data" style="margin: 5px;"></div>';
+	$output .=     '<div class="databox" id="snmp_data" style="margin: 5px;"></div>';
 	$output .=   '</div>';
 	$output .= '</div>';
 	$output .= '</div>';
diff --git a/pandora_console/include/javascript/pandora_snmp_browser.js b/pandora_console/include/javascript/pandora_snmp_browser.js
index fd202ad4dc..60f914c9e9 100644
--- a/pandora_console/include/javascript/pandora_snmp_browser.js
+++ b/pandora_console/include/javascript/pandora_snmp_browser.js
@@ -203,8 +203,9 @@ function hideOIDData() {
 
 	// Empty previous OID data
 	$("#snmp_data").empty();
-	
+
 	$("#snmp_data").css('display', 'none');
+	$(".forced_title_layer").css('display', 'none');
 }
 
 // Search the SNMP tree for a matching string
diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css
index 28c6e3691d..6601807581 100644
--- a/pandora_console/include/styles/pandora.css
+++ b/pandora_console/include/styles/pandora.css
@@ -4619,4 +4619,11 @@ form ul.form_flex li ul li{
 
 .events_bar {
 	margin:0 auto;
-}
\ No newline at end of file
+}
+
+#snmp_data {
+	background: #f9faf9;
+}
+#snmp_data .databox {
+	border: 0px;
+}

From 39ce3605206ead960fe52ca5802222d0f90dbb92 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Fri, 16 Mar 2018 11:12:19 +0100
Subject: [PATCH 09/17] [Logs] Scaped CDATAs on logs of windows agent

---
 pandora_agents/win32/modules/pandora_module.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc
index d7d5fb63c0..eac38c8fa1 100644
--- a/pandora_agents/win32/modules/pandora_module.cc
+++ b/pandora_agents/win32/modules/pandora_module.cc
@@ -532,6 +532,7 @@ Pandora_Module::getXml () {
 				try {
 					data_clean = strreplace (this->getDataOutput (data),
 								 "%", "%%" );
+					data_clean = strreplace (data_clean, "]]>", "]]><![CDATA[");
 				} catch (Module_Exception e) {
 					continue;
 				}
@@ -542,6 +543,7 @@ Pandora_Module::getXml () {
 			data = data_list->front ();
 			try {
 				data_clean = strreplace (this->getDataOutput (data), "%", "%%" );
+				data_clean = strreplace (data_clean, "]]>", "]]><![CDATA[");
 				module_xml += data_clean;
 
 			} catch (Module_Exception e) {

From 971a1125bcc0777283174911261dec78e17c1f28 Mon Sep 17 00:00:00 2001
From: fermin831 <fermin.hernandez@artica.es>
Date: Fri, 16 Mar 2018 11:48:59 +0100
Subject: [PATCH 10/17] [Logs] Scaped CDATAs on logs of linux plugin

---
 pandora_agents/unix/plugins/grep_log_module | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pandora_agents/unix/plugins/grep_log_module b/pandora_agents/unix/plugins/grep_log_module
index 0769128cbd..6fc1cff239 100755
--- a/pandora_agents/unix/plugins/grep_log_module
+++ b/pandora_agents/unix/plugins/grep_log_module
@@ -215,6 +215,7 @@ sub print_log (@) {
 		$output .= "<source><![CDATA[" . $Module_name . "]]></source>\n";
 		$output .= "<data><![CDATA[";
 		foreach my $line (@data) {
+			$line =~ s/\]\]/]]]]><![CDATA[/g;
 			$output .= $line;
 		}
 		$output .= "]]></data>";
@@ -229,6 +230,7 @@ sub print_log (@) {
 		$output .= "<type><![CDATA[async_string]]></type>\n";
 		$output .= "<datalist>\n";
 		foreach my $line (@data) {
+			$line =~ s/\]\]/]]]]><![CDATA[/g;
 			$output .= "<data><value><![CDATA[$line]]></value></data>\n";
 		}
 		$output .= "</datalist>\n";

From d881e0028d4fcb1642dbfd18d8ef21e83876334e Mon Sep 17 00:00:00 2001
From: daniel <daniel.barbero@artica.es>
Date: Fri, 16 Mar 2018 12:03:51 +0100
Subject: [PATCH 11/17] fixed errors detected SLA

---
 pandora_console/include/functions_modules.php | 27 +++++++------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php
index b940072a6a..dfe09384b7 100755
--- a/pandora_console/include/functions_modules.php
+++ b/pandora_console/include/functions_modules.php
@@ -1087,21 +1087,14 @@ function modules_get_agentmodule_descripcion ($id_agente_modulo) {
  *
  * @return string Module type of the given agent module.
  */
-function modules_get_agentmodule_type ($id_agentmodule, $metaconsole = false, $id_server = null) {
-	
-	if ($metaconsole) {
-		$server = db_get_row('tmetaconsole_setup', 'id', $id_server);
-		
-		$return = db_get_value ('id_tipo_modulo',
-			'tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
-		
-		metaconsole_restore_db();
-	}
-	else {
-		$return = db_get_value ('id_tipo_modulo',
-			'tagente_modulo', 'id_agente_modulo', (int) $id_agentmodule);
-	}
-	
+function modules_get_agentmodule_type ($id_agentmodule) {
+	$return = db_get_value (
+		'id_tipo_modulo',
+		'tagente_modulo',
+		'id_agente_modulo',
+		(int) $id_agentmodule
+	);
+
 	return (int) $return;
 }
 
@@ -2318,10 +2311,10 @@ function modules_change_relation_lock ($id_relation) {
  */
 function modules_get_first_date($id_agent_module, $datelimit = 0) {
 	global $config;
-	
+
 	//check datatype string or normal
 	$table = "tagente_datos";
-	$module_type_str = modules_get_type_name ($id_agent_module);
+	$module_type_str = modules_get_agentmodule_type($id_agent_module);
 	if (strstr ($module_type_str, 'string') !== false) {
 		$table = "tagente_datos_string";
 	}

From 4aa57b23666b8252b567d9344a5a7552c3e951e8 Mon Sep 17 00:00:00 2001
From: fbsanchez <fborja.sanchez@artica.es>
Date: Tue, 20 Mar 2018 11:59:53 +0100
Subject: [PATCH 12/17] Fixed plugin path in pandora_update_version

---
 extras/pandora_update_version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh
index 2b77dd8e02..17870d36e0 100755
--- a/extras/pandora_update_version.sh
+++ b/extras/pandora_update_version.sh
@@ -65,7 +65,7 @@ $PANDHOME_ENT/pandora_plugins/MTL/pandora_mtl.pl \
 $PANDHOME_ENT/pandora_plugins/Informix/informix.pl \
 $PANDHOME_ENT/pandora_plugins/Ruckus/ruckus.pl \
 $PANDHOME_ENT/pandora_plugins/UX/pandora_ux.pl \
-$PANDHOME_ENT/pandora_server/util/plugins/vmware-plugin.pl "
+$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl "
 PLUGIN_LIB_FILE="$CODEHOME/pandora_server/lib/PandoraFMS/PluginTools.pm"
 
 # Update version in spec files

From 19b566d4c28dd7b2e9e845dee41993cd3ca040c8 Mon Sep 17 00:00:00 2001
From: enriquecd <enrique.camargo@artica.com>
Date: Tue, 20 Mar 2018 15:42:37 +0100
Subject: [PATCH 13/17] Fix cluster id_os bug - #2090

---
 pandora_console/extras/mr/14.sql | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 pandora_console/extras/mr/14.sql

diff --git a/pandora_console/extras/mr/14.sql b/pandora_console/extras/mr/14.sql
new file mode 100644
index 0000000000..46e66e3ab5
--- /dev/null
+++ b/pandora_console/extras/mr/14.sql
@@ -0,0 +1,7 @@
+START TRANSACTION;
+
+UPDATE `tagente` SET `id_os` = 100 WHERE `id_os` = 21 and (select `id_os` from `tconfig_os` WHERE `id_os` = 21 and `name` = 'Cluster');
+
+DELETE FROM `tconfig_os` where `id_os` = 21 and `name` = 'Cluster';
+
+COMMIT;
\ No newline at end of file

From 364daa8579fa3ee89d64bab9e6209f201fc92327 Mon Sep 17 00:00:00 2001
From: danielmaya <daniel.maya@artica.es>
Date: Wed, 21 Mar 2018 16:51:08 +0100
Subject: [PATCH 14/17] Added group_id in cron job(mr and migrate)

---
 pandora_console/extras/mr/14.sql                       | 10 ++++++++++
 .../extras/pandoradb_migrate_6.0_to_7.0.mysql.sql      |  1 +
 2 files changed, 11 insertions(+)

diff --git a/pandora_console/extras/mr/14.sql b/pandora_console/extras/mr/14.sql
index 46e66e3ab5..837eb40bd5 100644
--- a/pandora_console/extras/mr/14.sql
+++ b/pandora_console/extras/mr/14.sql
@@ -4,4 +4,14 @@ UPDATE `tagente` SET `id_os` = 100 WHERE `id_os` = 21 and (select `id_os` from `
 
 DELETE FROM `tconfig_os` where `id_os` = 21 and `name` = 'Cluster';
 
+SET @st_oum721 = (SELECT IF(
+	(SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled') > 0, 
+	"ALTER TABLE tuser_task_scheduled ADD (id_grupo int(10) unsigned NOT NULL Default 0)", 
+	"0"
+));
+
+PREPARE pr_oum721 FROM @st_oum721;
+EXECUTE pr_oum721;
+DEALLOCATE PREPARE pr_oum721;
+
 COMMIT;
\ No newline at end of file
diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
index 4d67628920..87781d7a5f 100644
--- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql
@@ -1368,6 +1368,7 @@ END IF;
 SET @vv2 = (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'tuser_task_scheduled');
 IF @vv2>0 THEN
 	ALTER TABLE tuser_task_scheduled MODIFY args TEXT NOT NULL;
+	ALTER TABLE tuser_task_scheduled ADD (id_grupo int(10) unsigned NOT NULL Default 0);
 END IF;
 END;
 //

From f5e8d4f90ff86a25a41893da49b54be0d89631fe Mon Sep 17 00:00:00 2001
From: enriquecd <enrique.camargo@artica.com>
Date: Wed, 21 Mar 2018 19:18:24 +0100
Subject: [PATCH 15/17] Help icon in module creator - #2081

---
 pandora_console/godmode/agentes/configurar_agente.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index 3e0aac7af1..1dc4daea66 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -555,7 +555,7 @@ if ($id_agente) {
 			$help_header = 'plugins_tab';
 			break;
 		case "module":
-			$type_module_t = (int) get_parameter ('moduletype', '');
+			$type_module_t = get_parameter ('moduletype', '');
 			$tab_description = '- '. __('Modules');
 			if($type_module_t == 'webux'){
 				$help_header = 'wux_console';

From 243e24e56eb747c2ad23d383a16f30090ec21859 Mon Sep 17 00:00:00 2001
From: artica <artica.devel@gmail.com>
Date: Thu, 22 Mar 2018 00:01:23 +0100
Subject: [PATCH 16/17] Auto-updated build strings.

---
 pandora_agents/unix/DEBIAN/control             | 2 +-
 pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +-
 pandora_agents/unix/pandora_agent              | 2 +-
 pandora_agents/unix/pandora_agent.redhat.spec  | 2 +-
 pandora_agents/unix/pandora_agent.spec         | 2 +-
 pandora_agents/unix/pandora_agent_installer    | 2 +-
 pandora_agents/win32/installer/pandora.mpi     | 2 +-
 pandora_agents/win32/pandora.cc                | 2 +-
 pandora_agents/win32/versioninfo.rc            | 2 +-
 pandora_console/DEBIAN/control                 | 2 +-
 pandora_console/DEBIAN/make_deb_package.sh     | 2 +-
 pandora_console/include/config_process.php     | 2 +-
 pandora_console/install.php                    | 2 +-
 pandora_console/pandora_console.redhat.spec    | 2 +-
 pandora_console/pandora_console.spec           | 2 +-
 pandora_server/DEBIAN/control                  | 2 +-
 pandora_server/DEBIAN/make_deb_package.sh      | 2 +-
 pandora_server/lib/PandoraFMS/Config.pm        | 2 +-
 pandora_server/lib/PandoraFMS/PluginTools.pm   | 2 +-
 pandora_server/pandora_server.redhat.spec      | 2 +-
 pandora_server/pandora_server.spec             | 2 +-
 pandora_server/pandora_server_installer        | 2 +-
 pandora_server/util/pandora_db.pl              | 2 +-
 pandora_server/util/pandora_manage.pl          | 2 +-
 24 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control
index 998d883c51..5af97851a6 100644
--- a/pandora_agents/unix/DEBIAN/control
+++ b/pandora_agents/unix/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-agent-unix
-Version: 7.0NG.720-180321
+Version: 7.0NG.720-180322
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh
index cd8f91a9fd..827e42a56e 100644
--- a/pandora_agents/unix/DEBIAN/make_deb_package.sh
+++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.720-180321"
+pandora_version="7.0NG.720-180322"
 
 echo "Test if you has the tools for to make the packages."
 whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 2867fcbc66..130c867a06 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -42,7 +42,7 @@ my $Sem = undef;
 my $ThreadSem = undef;
 
 use constant AGENT_VERSION => '7.0NG.720';
-use constant AGENT_BUILD => '180321';
+use constant AGENT_BUILD => '180322';
 
 # Agent log default file size maximum and instances
 use constant DEFAULT_MAX_LOG_SIZE => 600000;
diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec
index 0bb6b96b3c..ec109b6c68 100644
--- a/pandora_agents/unix/pandora_agent.redhat.spec
+++ b/pandora_agents/unix/pandora_agent.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.720
-%define release     180321
+%define release     180322
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec
index 3de5e65d15..727d3d6cba 100644
--- a/pandora_agents/unix/pandora_agent.spec
+++ b/pandora_agents/unix/pandora_agent.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_agent_unix
 %define version     7.0NG.720
-%define release     180321
+%define release     180322
 
 Summary:            Pandora FMS Linux agent, PERL version
 Name:               %{name}
diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer
index 690f0e5e52..9a367e6c91 100755
--- a/pandora_agents/unix/pandora_agent_installer
+++ b/pandora_agents/unix/pandora_agent_installer
@@ -10,7 +10,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.720"
-PI_BUILD="180321"
+PI_BUILD="180322"
 OS_NAME=`uname -s`
 
 FORCE=0
diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi
index ecf3f1fadc..734cecfe42 100644
--- a/pandora_agents/win32/installer/pandora.mpi
+++ b/pandora_agents/win32/installer/pandora.mpi
@@ -186,7 +186,7 @@ UpgradeApplicationID
 {}
 
 Version
-{180321}
+{180322}
 
 ViewReadme
 {Yes}
diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc
index 49c1c7d9b2..188d7454c9 100644
--- a/pandora_agents/win32/pandora.cc
+++ b/pandora_agents/win32/pandora.cc
@@ -30,7 +30,7 @@ using namespace Pandora;
 using namespace Pandora_Strutils;
 
 #define PATH_SIZE    _MAX_PATH+1
-#define PANDORA_VERSION ("7.0NG.720(Build 180321)")
+#define PANDORA_VERSION ("7.0NG.720(Build 180322)")
 
 string pandora_path;
 string pandora_dir;
diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc
index a20eb79e32..3de8f1551a 100644
--- a/pandora_agents/win32/versioninfo.rc
+++ b/pandora_agents/win32/versioninfo.rc
@@ -11,7 +11,7 @@ BEGIN
       VALUE "LegalCopyright", "Artica ST"
       VALUE "OriginalFilename", "PandoraAgent.exe"
       VALUE "ProductName", "Pandora FMS Windows Agent"
-      VALUE "ProductVersion", "(7.0NG.720(Build 180321))"
+      VALUE "ProductVersion", "(7.0NG.720(Build 180322))"
       VALUE "FileVersion", "1.0.0.0"
     END
   END
diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control
index d441d4207c..aa7f25f878 100644
--- a/pandora_console/DEBIAN/control
+++ b/pandora_console/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-console
-Version: 7.0NG.720-180321
+Version: 7.0NG.720-180322
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh
index 82e7e40b1f..2c9364762c 100644
--- a/pandora_console/DEBIAN/make_deb_package.sh
+++ b/pandora_console/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.720-180321"
+pandora_version="7.0NG.720-180322"
 
 package_pear=0
 package_pandora=1
diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php
index c654b48fd2..05eb0ab0e8 100644
--- a/pandora_console/include/config_process.php
+++ b/pandora_console/include/config_process.php
@@ -22,7 +22,7 @@
 /**
  * Pandora build version and version 
  */
-$build_version = 'PC180321';
+$build_version = 'PC180322';
 $pandora_version = 'v7.0NG.720';
 
 // Do not overwrite default timezone set if defined.
diff --git a/pandora_console/install.php b/pandora_console/install.php
index 0a3ac1acf9..3725bf6847 100755
--- a/pandora_console/install.php
+++ b/pandora_console/install.php
@@ -71,7 +71,7 @@
 		<div style='height: 10px'>
 			<?php
 $version = '7.0NG.720';
-$build = '180321';
+$build = '180322';
 			$banner = "v$version Build $build";
 			
 			error_reporting(0);
diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec
index b1397231d1..f014ac5dbf 100644
--- a/pandora_console/pandora_console.redhat.spec
+++ b/pandora_console/pandora_console.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.720
-%define release     180321
+%define release     180322
 
 # User and Group under which Apache is running
 %define httpd_name  httpd
diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec
index 443fbc28e8..d8681212eb 100644
--- a/pandora_console/pandora_console.spec
+++ b/pandora_console/pandora_console.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_console
 %define version     7.0NG.720
-%define release     180321
+%define release     180322
 %define httpd_name      httpd
 # User and Group under which Apache is running
 %define httpd_name  apache2
diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control
index 5bf6ce8c9b..b004cf734e 100644
--- a/pandora_server/DEBIAN/control
+++ b/pandora_server/DEBIAN/control
@@ -1,5 +1,5 @@
 package: pandorafms-server
-Version: 7.0NG.720-180321
+Version: 7.0NG.720-180322
 Architecture: all
 Priority: optional
 Section: admin
diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh
index 6ca7a40a8c..bb5d6efaf5 100644
--- a/pandora_server/DEBIAN/make_deb_package.sh
+++ b/pandora_server/DEBIAN/make_deb_package.sh
@@ -14,7 +14,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-pandora_version="7.0NG.720-180321"
+pandora_version="7.0NG.720-180322"
 
 package_cpan=0
 package_pandora=1
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index b8364fdb6d..6f3e48961a 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -43,7 +43,7 @@ our @EXPORT = qw(
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.720";
-my $pandora_build = "180321";
+my $pandora_build = "180322";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 # Setup hash
diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm
index b31e623c40..c65a36c6a3 100644
--- a/pandora_server/lib/PandoraFMS/PluginTools.pm
+++ b/pandora_server/lib/PandoraFMS/PluginTools.pm
@@ -31,7 +31,7 @@ our @ISA = qw(Exporter);
 
 # version: Defines actual version of Pandora Server for this module only
 my $pandora_version = "7.0NG.720";
-my $pandora_build = "180321";
+my $pandora_build = "180322";
 our $VERSION = $pandora_version." ".$pandora_build;
 
 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec
index c7f2e5d382..9a87ae5704 100644
--- a/pandora_server/pandora_server.redhat.spec
+++ b/pandora_server/pandora_server.redhat.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.720
-%define release     180321
+%define release     180322
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec
index a190e8b030..80a197e3b4 100644
--- a/pandora_server/pandora_server.spec
+++ b/pandora_server/pandora_server.spec
@@ -3,7 +3,7 @@
 #
 %define name        pandorafms_server
 %define version     7.0NG.720
-%define release     180321
+%define release     180322
 
 Summary:            Pandora FMS Server
 Name:               %{name}
diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer
index cfa1cf7d0f..5b362ab884 100755
--- a/pandora_server/pandora_server_installer
+++ b/pandora_server/pandora_server_installer
@@ -9,7 +9,7 @@
 # **********************************************************************
 
 PI_VERSION="7.0NG.720"
-PI_BUILD="180321"
+PI_BUILD="180322"
 
 MODE=$1
 if [ $# -gt 1 ]; then
diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl
index 87db9b804f..dbf37ee39f 100644
--- a/pandora_server/util/pandora_db.pl
+++ b/pandora_server/util/pandora_db.pl
@@ -33,7 +33,7 @@ use PandoraFMS::Tools;
 use PandoraFMS::DB;
 
 # version: define current version
-my $version = "7.0NG.720 PS180321";
+my $version = "7.0NG.720 PS180322";
 
 # Pandora server configuration
 my %conf;
diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl
index 201ce190ba..cdb88b534d 100644
--- a/pandora_server/util/pandora_manage.pl
+++ b/pandora_server/util/pandora_manage.pl
@@ -36,7 +36,7 @@ use Encode::Locale;
 Encode::Locale::decode_argv;
 
 # version: define current version
-my $version = "7.0NG.720 PS180321";
+my $version = "7.0NG.720 PS180322";
 
 # save program name for logging
 my $progname = basename($0);

From 632845c9b3896f5eed550778611eebdb674a5797 Mon Sep 17 00:00:00 2001
From: enriquecd <enrique.camargo@artica.com>
Date: Thu, 22 Mar 2018 11:04:19 +0100
Subject: [PATCH 17/17] Adapt search bar to cluster id_os 100 - #1866

---
 pandora_console/operation/agentes/ver_agente.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php
index 6058b90724..52ad3766bc 100644
--- a/pandora_console/operation/agentes/ver_agente.php
+++ b/pandora_console/operation/agentes/ver_agente.php
@@ -106,7 +106,7 @@ if (is_ajax ()) {
 		
 		if($cluster_mode){
 			
-			$agent_id_os = db_get_all_rows_sql('select id_os from tconfig_os where id_os != 21');
+			$agent_id_os = db_get_all_rows_sql('select id_os from tconfig_os where id_os != 100');
 			
 			foreach ($agent_id_os as $key => $value) {
 				$agent_id_os_array[] = $agent_id_os[$key]['id_os'];