From e980e60025ed8370ec5efbc92f1621774c63f38d Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 6 Oct 2023 14:33:06 +0200 Subject: [PATCH 1/5] changed behavior of prediction modules creation --- .../module_manager_editor_prediction.php | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index eb85a05618..ff5043fd33 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -131,9 +131,10 @@ if ($module_service_synthetic_selector !== ENTERPRISE_NOT_HOOK) { } $data = []; -$data[0] = __('Agent'); -$data[1] = __('Module'); -$data[2] = __('Period'); + +$data[0] = __('Module'); +$data[1] = __('Period'); + $table_simple->cellclass['caption_prediction_module'][0] = 'w33p'; $table_simple->cellclass['caption_prediction_module'][1] = 'w33p'; $table_simple->cellclass['caption_prediction_module'][2] = 'w33p'; @@ -163,34 +164,61 @@ $params['none_module_text'] = __('Select Module'); $params['use_hidden_input_idagent'] = true; $params['input_style'] = 'width: 100%;'; $params['hidden_input_idagent_id'] = 'hidden-id_agente_module_prediction'; -$data[0] = ui_print_agent_autocomplete_input($params); -if ($id_agente > 0) { - $predictionModuleInput = html_print_select_from_sql( - 'SELECT id_agente_modulo, nombre - FROM tagente_modulo - WHERE delete_pending = 0 - AND history_data = 1 - AND id_agente = '.$id_agente_clean.' - AND id_agente_modulo <> '.$id_agente_modulo, +if (strstr($page, 'policy_modules') === false) { + $modules = agents_get_modules($id_agente); + + $predictionModuleInput = html_print_select( + $modules, 'prediction_module', $prediction_module, '', - __('Select Module'), + '', 0, true, false, true, + '', false, - 'width: 100%;' + false, + false, + false, + false, + '', + false, + false, + true ); } else { - $predictionModuleInput = ''; + $modules = index_array(policies_get_modules($policy_id, false, ['id', 'name'])); + + $predictionModuleInput = html_print_select( + $modules, + 'id_module_policy', + $module['custom_integer_1'], + '', + '', + 0, + true, + false, + true, + '', + false, + false, + false, + false, + false, + '', + false, + false, + true + ); } -$data[1] = $predictionModuleInput; -$data[2] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); -$data[2] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); +$data[0] = $predictionModuleInput; +$data[1] = html_print_select([__('Weekly'), __('Monthly'), __('Daily')], 'custom_integer_2', $custom_integer_2, '', '', 0, true, false, true, '', false, 'width: 100%;'); +$data[1] .= html_print_input_hidden('id_agente_module_prediction', $id_agente, true); + $table_simple->cellclass['prediction_module'][0] = 'w33p'; $table_simple->cellclass['prediction_module'][1] = 'w33p'; $table_simple->cellclass['prediction_module'][2] = 'w33p'; From fbe2629de362d4dd1653eacdeff6522f03ce27d6 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 13 Oct 2023 10:39:33 +0200 Subject: [PATCH 2/5] fix policy synthetic module form --- .../godmode/agentes/module_manager_editor_prediction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index ff5043fd33..e8fee22a87 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -292,7 +292,7 @@ if ($selector_form !== ENTERPRISE_NOT_HOOK) { } // Synthetic modules are an Enterprise feature. -$synthetic_module_form = enterprise_hook('get_synthetic_module_form'); +$synthetic_module_form = enterprise_hook('get_synthetic_module_form', [$policy_id]); if ($synthetic_module_form !== ENTERPRISE_NOT_HOOK) { $data = []; $data[0] = $synthetic_module_form; From c67a8ba25d09033756afa38af41113812dfbc20a Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 13 Oct 2023 14:31:17 +0200 Subject: [PATCH 3/5] remove required --- .../godmode/agentes/module_manager_editor_prediction.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index e8fee22a87..a2806c5781 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -186,8 +186,7 @@ if (strstr($page, 'policy_modules') === false) { false, '', false, - false, - true + false ); } else { $modules = index_array(policies_get_modules($policy_id, false, ['id', 'name'])); From 36f12d543255a47e987a1273aa84d0bd4a3c1ab6 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 18 Oct 2023 20:16:40 +0200 Subject: [PATCH 4/5] minor fix --- .../agentes/module_manager_editor_prediction.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index a2806c5781..095708d2b1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -186,7 +186,15 @@ if (strstr($page, 'policy_modules') === false) { false, '', false, - false + false, + false, + false, + true, + false, + false, + '', + false, + 'pm' ); } else { $modules = index_array(policies_get_modules($policy_id, false, ['id', 'name'])); From e90497df6123e8f7c53f6f1406a93883703cc697 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 18 Oct 2023 20:17:18 +0200 Subject: [PATCH 5/5] minor fix --- pandora_console/include/functions_html.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 0dd7808092..9c12bba184 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -774,6 +774,7 @@ function html_print_select( $select2_multiple_enable_all=false, $form='', $order=false, + $custom_id=null ) { $output = "\n"; @@ -789,6 +790,10 @@ function html_print_select( $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); + if ($custom_id !== null) { + $id = $custom_id; + } + $attributes = ''; if (!empty($script)) { $attributes .= ' onchange="'.$script.'"';