diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 6c2eb7d3e1..02fa0c5154 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -915,7 +915,25 @@ function html_print_select( ui_require_javascript_file('select2.min'); } - $output .= ''; + $output .= ''; } if ($return) { diff --git a/pandora_console/include/lib/Module.php b/pandora_console/include/lib/Module.php index 18f4366d3c..9bb770c3bf 100644 --- a/pandora_console/include/lib/Module.php +++ b/pandora_console/include/lib/Module.php @@ -88,7 +88,8 @@ class Module extends Entity * @param array $params Search parameters (fields from tagente_modulo). * @param integer $limit Limit results to N rows. * - * @return array|null of PandoraFMS\Module found or null if not found. + * @return object|array|null PandoraFMS\Module found if limited, array of Modules + * or null if not found. * @throws \Exception On error. */ public static function search( diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 52083168e3..b39830610f 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -48,6 +48,7 @@ if (is_ajax()) { $get_agent_status_tooltip = (bool) get_parameter('get_agent_status_tooltip'); $get_agents_group_json = (bool) get_parameter('get_agents_group_json'); $get_modules_group_json = (bool) get_parameter('get_modules_group_json'); + $filter_modules_group_json = (bool) get_parameter('filter_modules_group_json'); $get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json'); $get_agent_modules_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_json_for_multiple_agents'); $get_agent_modules_alerts_json_for_multiple_agents = (bool) get_parameter('get_agent_modules_alerts_json_for_multiple_agents'); @@ -283,6 +284,40 @@ if (is_ajax()) { } } + if ($filter_modules_group_json) { + $modules = (array) get_parameter('modules', []); + $existing_modules = []; + + foreach ($modules as $def) { + $data = explode('|', $def); + $id_agent = $data[0]; + $module_name = $data[1]; + + try { + $module = PandoraFMS\Module::search( + [ + 'id_agente' => $id_agent, + 'nombre' => $module_name, + ], + 1 + ); + + if ($module !== null) { + $existing_modules[] = [ + 'id' => $module->id_agente_modulo(), + 'text' => io_safe_output( + $module->agent()->alias().' » '.$module->nombre() + ), + ]; + } + } catch (Exception $e) { + continue; + } + } + + echo json_encode($existing_modules); + } + if ($get_modules_group_value_name_json) { $id_agents = get_parameter('id_agents'); $selection = get_parameter('selection');