From 92f57e6176412e6720b4975b3f481da87acd7be8 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Wed, 23 Dec 2020 13:43:54 +0100 Subject: [PATCH] Added macros to reports items list --- .../reporting_builder.list_items.php | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index ff4c46abf8..722182405d 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -515,18 +515,68 @@ foreach ($items as $item) { $style = json_decode(io_safe_output($item['style']), true); + + // Macros + $items_macro = []; + + if (!empty($item['id_agent'])) { + $id_agent = $item['id_agent']; + // Add macros name. + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + + $items_macro_agent = [ + 'id_agent' => $id_agent, + 'agent_description' => $agent_description, + 'agent_group' => $agent_group, + 'agent_address' => $agent_address, + 'agent_alias' => $agent_alias, + ]; + + $items_macro = array_merge($items_macro, $items_macro_agent); + } + + if (!empty($item['id_agent_module'])) { + $id_agent_module = $item['id_agent_module']; + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + + $items_macro_module = [ + 'id_agent_module' => $id_agent_module, + 'module_name' => $module_name, + 'module_description' => $module_description, + ]; + + $items_macro = array_merge($items_macro, $items_macro_module); + } + + + if ($style['name_label'] != '') { $text = empty($style['name_label']) ? $item['description'] : $style['name_label']; - $row[5] = ui_print_truncate_text($text, 'description', true, true); } else { if ($item['name'] == '' && $item['description'] == '') { - $row[5] = '-'; + $text = '-'; } else { $text = empty($item['name']) ? $item['description'] : $item['name']; - $row[5] = ui_print_truncate_text($text, 'description', true, true); } } + // Apply macros + $items_macro['type'] = $item['type']; + $text = reporting_label_macro( + $items_macro, + $text + ); + $row[5] = ui_print_truncate_text($text, 'description', true, true); + + $row[6] = ''; if (check_acl($config['id_user'], $item['id_group'], 'RM')) {