diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php
index bdace865a2..42d7155f2e 100644
--- a/pandora_console/godmode/agentes/agent_manager.php
+++ b/pandora_console/godmode/agentes/agent_manager.php
@@ -322,7 +322,16 @@ $table_primary_group = '
'.__('P
$table_primary_group .= '
';
// Cannot change primary group if user have not permission for that group.
if (isset($groups[$grupo]) || $new_agent) {
- $table_primary_group .= html_print_select_groups(false, 'AR', false, 'grupo', $grupo, '', '', 0, true);
+ $table_primary_group .= html_print_input(
+ [
+ 'type' => 'select_groups',
+ 'returnAllGroup' => false,
+ 'name' => 'grupo',
+ 'selected' => $grupo,
+ 'return' => true,
+ 'required' => true,
+ ]
+ );
} else {
$table_primary_group .= groups_get_name($grupo);
$table_primary_group .= html_print_input_hidden('grupo', $grupo, true);
diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php
index 422d4d0f13..ef3598e081 100644
--- a/pandora_console/godmode/agentes/configurar_agente.php
+++ b/pandora_console/godmode/agentes/configurar_agente.php
@@ -193,7 +193,7 @@ if ($create_agent) {
$direccion_agente = io_safe_input($direccion_agente);
$nombre_agente = hash('sha256', $alias.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000)));
- $grupo = (int) get_parameter_post('grupo');
+ $grupo = get_parameter_post('grupo', null);
$intervalo = (string) get_parameter_post('intervalo', SECONDS_5MINUTES);
$comentarios = (string) get_parameter_post('comentarios', '');
$modo = (int) get_parameter_post('modo');
@@ -215,6 +215,13 @@ if ($create_agent) {
$secondary_groups = (string) get_parameter('secondary_hidden', '');
$fields = db_get_all_fields_in_table('tagent_custom_fields');
+ if ($grupo === null) {
+ $agent_creation_error = __('No group specified');
+ $agent_created_ok = 0;
+ } else {
+ $grupo = (int) $grupo;
+ }
+
if ($fields === false) {
$fields = [];
}
@@ -229,7 +236,7 @@ if ($create_agent) {
if ($alias == '') {
$agent_creation_error = __('No agent alias specified');
$agent_created_ok = 0;
- } else {
+ } else if ($agent_created_ok != 0) {
if ($alias_as_name) {
$sql = 'SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"';
$exists_alias = db_get_row_sql($sql);
diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php
index 7beced680d..cfbe805e2c 100644
--- a/pandora_console/include/functions_html.php
+++ b/pandora_console/include/functions_html.php
@@ -435,6 +435,7 @@ function html_print_select_style($fields, $name, $selected='', $style='', $scrip
* @param array $include_groups Add groups to select.
* @param string $size Style, size (width) of element.
* @param boolean $simple_multiple_options Discovery simple multiple inputs.
+ * @param boolean $required Required input.
*
* @return string HTML code if return parameter is true.
*/
@@ -460,7 +461,8 @@ function html_print_select_groups(
$delete_groups=false,
$include_groups=false,
$size=false,
- $simple_multiple_options=false
+ $simple_multiple_options=false,
+ $required=false
) {
$output = '';
@@ -528,7 +530,8 @@ function html_print_select_groups(
false,
'',
false,
- $simple_multiple_options
+ $simple_multiple_options,
+ $required
);
if (empty($size) === true) {
@@ -644,7 +647,8 @@ function html_print_select(
$modal=false,
$message='',
$select_all=false,
- $simple_multiple_options=false
+ $simple_multiple_options=false,
+ $required=false
) {
$output = "\n";
@@ -694,7 +698,11 @@ function html_print_select(
$styleText = 'style="'.$style.'"';
}
- $output .= '