diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 7965dbc566..d2f3f17afe 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -999,7 +999,6 @@ if ($update_agent) { $fields = db_get_all_fields_in_table('tagent_custom_fields'); $secondary_groups = (string) get_parameter('secondary_hidden', ''); - if ($fields === false) { $fields = []; } diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index bfc3c2b6d1..b83b51314e 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -140,8 +140,8 @@ if ($update_agents) { $values['safe_mode_module'] = '0'; } - $secondary_groups_added = (string) get_parameter('secondary_hidden_added', ''); - $secondary_groups_removed = (string) get_parameter('secondary_hidden_removed', ''); + $secondary_groups_added = (array) get_parameter('secondary_groups_added', []); + $secondary_groups_removed = (array) get_parameter('secondary_groups_removed', []); $fields = db_get_all_fields_in_table('tagent_custom_fields'); @@ -389,8 +389,8 @@ if ($update_agents) { 'agents_update_secondary_groups', [ $id_agent, - explode(',', $secondary_groups_added), - explode(',', $secondary_groups_removed), + $secondary_groups_added, + $secondary_groups_removed, ] ); } @@ -743,9 +743,10 @@ if (enterprise_installed() === true) { $agent, $id_agente, [ - 'container' => true, - 'id_form' => 'form_agent', - 'extra_id' => '_added', + 'container' => true, + 'id_form' => 'form_agent', + 'extra_id' => '_added', + 'only_select' => true, ] ); @@ -754,9 +755,10 @@ if (enterprise_installed() === true) { $agent, $id_agente, [ - 'container' => true, - 'id_form' => 'form_agent', - 'extra_id' => '_removed', + 'container' => true, + 'id_form' => 'form_agent', + 'extra_id' => '_removed', + 'only_select' => true, ] ); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 9353e34f7f..f479a035e7 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -5639,15 +5639,24 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) $options['id_form'] = 'form_agent'; } - if (empty($options) === '' || isset($options['id_form']) === false) { + if (empty($options) === '' || isset($options['extra_id']) === false) { $options['extra_id'] = ''; } + if (empty($options) === '' || isset($options['only_select']) === false) { + $options['only_select'] = false; + } + $secondary_groups_selected = enterprise_hook( 'agents_get_secondary_groups', [$id_agente] ); + $name = 'secondary_groups'.$options['extra_id']; + if ($options['only_select'] === true) { + $name = 'secondary_groups'.$options['extra_id'].'[]'; + } + $adv_secondary_groups_left = html_print_select_groups( // Id_user. // Use the current user to select the groups. @@ -5660,7 +5669,7 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) false, // Name. // HTML id. - 'secondary_groups'.$options['extra_id'], + $name, // Selected. // No select any by default. '', @@ -5714,89 +5723,93 @@ function html_print_select_agent_secondary($agent, $id_agente, $options=[]) // Simple_multiple_options. ); - $dictionary = base64_encode( - json_encode( + if ($options['only_select'] === false) { + $dictionary = base64_encode( + json_encode( + [ + 'primary_group' => __('Primary group cannot be secondary too.'), + 'strNone' => __('None'), + ] + ) + ); + + $adv_secondary_groups_arrows = html_print_input_image( + 'add_secondary', + 'images/darrowright_green.png', + 1, + '', + true, [ - 'primary_group' => __('Primary group cannot be secondary too.'), - 'strNone' => __('None'), + 'id' => 'right_autorefreshlist'.$options['extra_id'], + 'title' => __('Add secondary groups'), + 'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');', ] - ) - ); + ); - $adv_secondary_groups_arrows = html_print_input_image( - 'add_secondary', - 'images/darrowright_green.png', - 1, - '', - true, - [ - 'id' => 'right_autorefreshlist'.$options['extra_id'], - 'title' => __('Add secondary groups'), - 'onclick' => 'agent_manager_add_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');', - ] - ); + $adv_secondary_groups_arrows .= html_print_input_image( + 'remove_secondary', + 'images/darrowleft_green.png', + 1, + '', + true, + [ + 'id' => 'left_autorefreshlist'.$options['extra_id'], + 'title' => __('Remove secondary groups'), + 'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');', + ] + ); - $adv_secondary_groups_arrows .= html_print_input_image( - 'remove_secondary', - 'images/darrowleft_green.png', - 1, - '', - true, - [ - 'id' => 'left_autorefreshlist'.$options['extra_id'], - 'title' => __('Remove secondary groups'), - 'onclick' => 'agent_manager_remove_secondary_groups(event, '.$id_agente.',\''.$options['extra_id'].'\', \''.$options['id_form'].'\', \''.$dictionary.'\');', - ] - ); - - $adv_secondary_groups_right .= html_print_select( + $adv_secondary_groups_right .= html_print_select( // Values. - $secondary_groups_selected['for_select'], - // HTML id. - 'secondary_groups_selected'.$options['extra_id'], - // Selected. - '', - // Javascript onChange code. - '', - // Nothing selected. - false, - // Nothing selected. - 0, - // Return HTML (not echo). - true, - // Multiple selection. - true, - // Sort. - true, - // Class. - '', - // Disabled. - false, - // Style. - 'min-width:170px;' - ); + $secondary_groups_selected['for_select'], + // HTML id. + 'secondary_groups_selected'.$options['extra_id'], + // Selected. + '', + // Javascript onChange code. + '', + // Nothing selected. + false, + // Nothing selected. + 0, + // Return HTML (not echo). + true, + // Multiple selection. + true, + // Sort. + true, + // Class. + '', + // Disabled. + false, + // Style. + 'min-width:170px;' + ); - $output = ''; - if (isset($options['container']) === true - && $options['container'] === true - ) { - $output = '
'; - } + $output = ''; + if (isset($options['container']) === true + && $options['container'] === true + ) { + $output = '
'; + } - $output .= '
'; - $output .= $adv_secondary_groups_left; - $output .= '
'; - $output .= '
'; - $output .= $adv_secondary_groups_arrows; - $output .= '
'; - $output .= '
'; - $output .= $adv_secondary_groups_right; - $output .= '
'; - - if (isset($options['container']) === true - && $options['container'] === true - ) { + $output .= '
'; + $output .= $adv_secondary_groups_left; $output .= '
'; + $output .= '
'; + $output .= $adv_secondary_groups_arrows; + $output .= '
'; + $output .= '
'; + $output .= $adv_secondary_groups_right; + $output .= '
'; + + if (isset($options['container']) === true + && $options['container'] === true + ) { + $output .= '
'; + } + } else { + $output .= $adv_secondary_groups_left; } return $output;