Merge branch '2219-Query_satura_base_de_datos_NT' into 'develop'

tags secondary groups patch

See merge request artica/pandorafms!1452
This commit is contained in:
vgilc 2018-04-26 15:11:43 +02:00
commit 830a2090fb
1 changed files with 25 additions and 7 deletions

View File

@ -719,10 +719,10 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
function tags_get_acl_tags_module_condition($acltags, $modules_table = '') { function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
if (!empty($modules_table)) if (!empty($modules_table))
$modules_table .= '.'; $modules_table .= '.';
$condition = ''; $condition = '';
$group_conditions = array(); $group_conditions = array();
// The acltags array contains the groups with the acl propagation applied // The acltags array contains the groups with the acl propagation applied
// after the changes done into the 'tags_get_user_groups_and_tags' function. // after the changes done into the 'tags_get_user_groups_and_tags' function.
foreach ($acltags as $group_id => $group_tags) { foreach ($acltags as $group_id => $group_tags) {
@ -733,8 +733,9 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
AND ttmc.id_tag IN (%s)', AND ttmc.id_tag IN (%s)',
is_array($group_tags) ? implode(',', $group_tags) : $group_tags); is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
} }
// FIXME: Not properly way to increse performance
$agent_condition = sprintf('SELECT tamc.id_agente_modulo if(enterprise_hook('agents_is_using_secondary_groups')){
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
FROM tagente_modulo tamc FROM tagente_modulo tamc
%s %s
INNER JOIN tagente tac INNER JOIN tagente tac
@ -743,10 +744,21 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
ON tasg.id_agent = tac.id_agente ON tasg.id_agent = tac.id_agente
WHERE (tac.id_grupo = %d OR tasg.id_group = %d)', WHERE (tac.id_grupo = %d OR tasg.id_group = %d)',
$tag_join, $group_id, $group_id); $tag_join, $group_id, $group_id);
}
else{
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
FROM tagente_modulo tamc
%s
INNER JOIN tagente tac
ON tamc.id_agente = tac.id_agente
AND tac.id_grupo = %d',
$tag_join, $group_id);
}
$sql_condition = sprintf('(%sid_agente_modulo IN (%s))', $modules_table, $agent_condition); $sql_condition = sprintf('(%sid_agente_modulo IN (%s))', $modules_table, $agent_condition);
$group_conditions[] = $sql_condition; $group_conditions[] = $sql_condition;
$i++; $i++;
} }
@ -859,7 +871,13 @@ function tags_get_acl_tags_event_condition($acltags, $meta = false, $force_group
// Tags condition (The module has at least one of the restricted tags) // Tags condition (The module has at least one of the restricted tags)
$tags_condition = ''; $tags_condition = '';
if (empty($group_tags)) { if (empty($group_tags)) {
$tags_condition = "id_grupo = ".$group_id . " OR id_group = " . $group_id; // FIXME: Not properly way to increse performance
if(enterprise_hook('agents_is_using_secondary_groups')){
$tags_condition = "id_grupo = ".$group_id . " OR id_group = " . $group_id;
}
else{
$tags_condition = "id_grupo = ".$group_id;
}
} }
else { else {
if (!is_array($group_tags)) { if (!is_array($group_tags)) {