From 51d7104de79d370a462b4452b8ae7b2d15b10a2f Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Tue, 2 Jul 2019 18:09:52 +0200 Subject: [PATCH] fix item name macros when using report templates --- pandora_console/include/functions_agents.php | 2 +- .../include/functions_reporting.php | 51 ++++++++++++++++--- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index affa4269d4..1ed3c028bd 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1531,7 +1531,7 @@ function agents_get_alias($id_agent, $case='none') return $cache[$case][$id_agent]; } - if ($config['dbconnection_cache'] == null && is_metaconsole()) { + if (is_metaconsole()) { $alias = (string) db_get_value('alias', 'tmetaconsole_agent', 'id_tagente', (int) $id_agent); } else { $alias = (string) db_get_value('alias', 'tagente', 'id_agente', (int) $id_agent); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 00860ac116..46359c1471 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -11488,17 +11488,32 @@ function reporting_label_macro($item, $label) } if (preg_match('/_agentdescription_/', $label)) { - $agent_name = agents_get_description($item['id_agent']); + if (!is_metaconsole()) { + $agent_name = agents_get_description($item['id_agent']); + } else { + $agent_name = $item['agent_description']; + } + $label = str_replace('_agentdescription_', $agent_name, $label); } if (preg_match('/_agentgroup_/', $label)) { - $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); + if (!is_metaconsole()) { + $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); + } else { + $agent_name = $item['agent_group']; + } + $label = str_replace('_agentgroup_', $agent_name, $label); } if (preg_match('/_address_/', $label)) { - $agent_name = agents_get_address($item['id_agent']); + if (!is_metaconsole()) { + $agent_name = agents_get_address($item['id_agent']); + } else { + $agent_name = $item['agent_address']; + } + $label = str_replace('_address_', $agent_name, $label); } break; @@ -11537,7 +11552,11 @@ function reporting_label_macro($item, $label) if (count($item['agents']) > 1) { $agent_name = ''; } else { - $agent_name = agents_get_description($item['id_agent']); + if (!is_metaconsole()) { + $agent_name = agents_get_description($item['id_agent']); + } else { + $agent_name = $item['agent_description']; + } } $label = str_replace('_agentdescription_', $agent_name, $label); @@ -11547,7 +11566,11 @@ function reporting_label_macro($item, $label) if (count($item['agents']) > 1) { $agent_name = ''; } else { - $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); + if (!is_metaconsole()) { + $agent_name = groups_get_name(agents_get_agent_group($item['id_agent']), true); + } else { + $agent_name = $item['agent_group']; + } } $label = str_replace('_agentgroup_', $agent_name, $label); @@ -11557,7 +11580,11 @@ function reporting_label_macro($item, $label) if (count($item['agents']) > 1) { $agent_name = ''; } else { - $agent_name = agents_get_address($item['id_agent']); + if (!is_metaconsole()) { + $agent_name = agents_get_address($item['id_agent']); + } else { + $agent_name = $item['agent_address']; + } } $label = str_replace('_address_', $agent_name, $label); @@ -11567,7 +11594,11 @@ function reporting_label_macro($item, $label) if ($item['modules'] > 1) { $module_name = $item['modules'].__(' modules'); } else { - $module_name = modules_get_agentmodule_name($item['id_agent_module']); + if (!is_metaconsole()) { + $module_name = modules_get_agentmodule_name($item['id_agent_module']); + } else { + $module_name = $item['module_name']; + } } $label = str_replace('_module_', $module_name, $label); @@ -11577,7 +11608,11 @@ function reporting_label_macro($item, $label) if ($item['modules'] > 1) { $module_description = ''; } else { - $module_description = modules_get_agentmodule_descripcion($item['id_agent_module']); + if (!is_metaconsole()) { + $module_description = modules_get_agentmodule_descripcion($item['id_agent_module']); + } else { + $module_description = $item['module_description']; + } } $label = str_replace('_moduledescription_', $module_description, $label);