Merge branch 'ent-9426-Error-SQL-en-eventos-con-usuario-no-admin' into 'develop'

fixed event filter

See merge request artica/pandorafms!5063
This commit is contained in:
Daniel Rodriguez 2022-08-23 13:38:18 +00:00
commit 3e7a21fe2e
2 changed files with 26 additions and 8 deletions

View File

@ -1279,7 +1279,8 @@ function events_get_all(
// Table tag for id_grupo.
'te.',
// Alt table tag for id_grupo.
$user_admin_group_all
$user_admin_group_all,
(bool) $filter['search_secondary_groups']
);
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
} else if (check_acl($config['id_user'], 0, 'EW')) {
@ -1305,7 +1306,8 @@ function events_get_all(
// Table tag for id_grupo.
'te.',
// Alt table tag for id_grupo.
$user_admin_group_all
$user_admin_group_all,
(bool) $filter['search_secondary_groups']
);
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
} else if (check_acl($config['id_user'], 0, 'EM')) {
@ -1331,7 +1333,8 @@ function events_get_all(
// Table tag for id_grupo.
'te.',
// Alt table tag for id_grupo.
$user_admin_group_all
$user_admin_group_all,
(bool) $filter['search_secondary_groups']
);
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
}

View File

@ -751,7 +751,8 @@ function tags_get_acl_tags(
$childrens_ids=[],
$force_group_and_tag=false,
$id_grupo_table_pretag='',
$alt_id_grupo_table_pretag=''
$alt_id_grupo_table_pretag='',
$search_secondary_group=true
) {
global $config;
@ -831,7 +832,8 @@ function tags_get_acl_tags(
$force_group_and_tag,
false,
$id_grupo_table_pretag,
$alt_id_grupo_table_pretag
$alt_id_grupo_table_pretag,
$search_secondary_group
);
if (!empty($condition)) {
@ -933,7 +935,8 @@ function tags_get_acl_tags_event_condition(
$force_group_and_tag=false,
$force_equal=false,
$id_grupo_table_pretag='',
$alt_id_grupo_table_pretag=''
$alt_id_grupo_table_pretag='',
$search_secondary_group=true
) {
global $config;
$condition = [];
@ -951,7 +954,13 @@ function tags_get_acl_tags_event_condition(
// Group condition (The module belongs to an agent of the group X)
// $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_children_ids($group_id, true))));.
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id.')';
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id;
if ($search_secondary_group === true) {
$group_condition .= ' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id;
}
$group_condition .= ')';
// Tags condition (The module has at least one of the restricted tags).
$tags_condition = '';
@ -987,7 +996,13 @@ function tags_get_acl_tags_event_condition(
}
$in_group = implode(',', $without_tags);
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR '.$alt_id_grupo_table_pretag.'id_group IN (%s))', $in_group, $in_group);
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s)', $in_group);
if ($search_secondary_group === true) {
$condition .= sprintf(' OR '.$alt_id_grupo_table_pretag.'id_group IN (%s)', $in_group);
}
$condition .= ')';
}
$condition = !empty($condition) ? "($condition)" : '';