Merge branch 'ent-9011-Fallo-permisos-en-paradas-planificadas' into 'develop'

fixed permissions in selectors

See merge request artica/pandorafms!4931
This commit is contained in:
Daniel Rodriguez 2022-06-08 09:10:51 +00:00
commit a2c1b38a3f
2 changed files with 19 additions and 4 deletions

View File

@ -539,6 +539,12 @@ if ($id_downtime > 0) {
// only action to postpone on once type is enabled and the other are disabled. // only action to postpone on once type is enabled and the other are disabled.
$disabled_in_execution = (int) $running; $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 = new StdClass();
$table->class = 'databox filters'; $table->class = 'databox filters';
$table->width = '100%'; $table->width = '100%';
@ -557,7 +563,7 @@ $table->data[1][0] = __('Group');
$table->data[1][1] = '<div class="w250px">'.html_print_select_groups( $table->data[1][1] = '<div class="w250px">'.html_print_select_groups(
false, false,
$access, $access,
true, $return_all_group,
'id_group', 'id_group',
$id_group, $id_group,
'', '',
@ -793,7 +799,7 @@ $table->width = '100%';
$table->data = []; $table->data = [];
$table->data[0][0] = __('Group filter'); $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').'&nbsp&nbsp'.html_print_checkbox('recursion', 1, $recursion, true, false, ''); $table->data[0][2] = __('Recursion').'&nbsp&nbsp'.html_print_checkbox('recursion', 1, $recursion, true, false, '');
$table->data[1][0] = __('Available agents'); $table->data[1][0] = __('Available agents');

View File

@ -697,6 +697,15 @@ if (is_ajax()) {
asort($result); asort($result);
} else { } else {
if ($idAgents[0] < 0) { 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') { if ($selection_mode == 'common') {
$sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0'; $sql_agent_total = 'SELECT count(*) FROM tagente WHERE disabled=0';
$agent_total = db_get_value_sql($sql_agent_total); $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 JOIN (SELECT COUNT(*) AS num_names, nombre FROM tagente_modulo
WHERE disabled=0 AND delete_pending=0 GROUP BY nombre) AS tj 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", 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" (empty($where_tags)) ? '' : " WHERE 1=1 $where_tags"
); );
} else { } else {
$sql = sprintf( $sql = sprintf(
'SELECT t1.nombre, t1.id_agente_modulo FROM tagente_modulo t1 %s %s', '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" (empty($where_tags)) ? '' : " WHERE 1=1 $where_tags"
); );
} }