diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 4eec189958..f17fbc0ccf 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -539,6 +539,12 @@ if ($id_downtime > 0) { // only action to postpone on once type is enabled and the other are disabled. $disabled_in_execution = (int) $running; +$return_all_group = false; + +if (users_can_manage_group_all('AW') === true || $disabled) { + $return_all_group = true; +} + $table = new StdClass(); $table->class = 'databox filters'; $table->width = '100%'; @@ -557,7 +563,7 @@ $table->data[1][0] = __('Group'); $table->data[1][1] = '
'.html_print_select_groups( false, $access, - true, + $return_all_group, 'id_group', $id_group, '', @@ -793,7 +799,7 @@ $table->width = '100%'; $table->data = []; $table->data[0][0] = __('Group filter'); -$table->data[0][1] = html_print_select_groups(false, $access, true, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;'); +$table->data[0][1] = html_print_select_groups(false, $access, $return_all_group, 'filter_group', $filter_group, '', '', '', true, false, true, '', false, 'min-width:180px;margin-right:15px;'); $table->data[0][2] = __('Recursion').'  '.html_print_checkbox('recursion', 1, $recursion, true, false, ''); $table->data[1][0] = __('Available agents'); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 3ce033fbe3..3c4eebb991 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -697,6 +697,15 @@ if (is_ajax()) { asort($result); } else { if ($idAgents[0] < 0) { + // Get all user's groups. + $id_group = array_keys(users_get_groups($config['id_user'])); + + if (is_array($id_group)) { + $id_group = implode(',', $id_group); + } + + $where_tags .= ' AND tagente.id_grupo IN ('.$id_group.')'; + if ($selection_mode == 'common') { $sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0'; $agent_total = db_get_value_sql($sql_agent_total); @@ -705,13 +714,13 @@ if (is_ajax()) { JOIN (SELECT COUNT(*) AS num_names, nombre FROM tagente_modulo WHERE disabled=0 AND delete_pending=0 GROUP BY nombre) AS tj ON tj.num_names = $agent_total AND tj.nombre = t1.nombre %s %s", - $sql_tags_join, + ($sql_tags_join === '') ? 'INNER JOIN tagente ON tagente.id_agente = t1.id_agente' : '', (empty($where_tags)) ? '' : " WHERE 1=1 $where_tags" ); } else { $sql = sprintf( 'SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 %s %s', - $sql_tags_join, + ($sql_tags_join === '') ? 'INNER JOIN tagente ON tagente.id_agente = t1.id_agente' : '', (empty($where_tags)) ? '' : " WHERE 1=1 $where_tags" ); }