Fixed the acl tags with groups without tags. Ticket: #1611

(cherry picked from commit 668d029047)
This commit is contained in:
mdtrooper 2014-12-04 13:03:37 +01:00
parent 452693e9df
commit bd9edbd3b7
1 changed files with 31 additions and 14 deletions

View File

@ -636,7 +636,10 @@ function tags_get_tags_formatted ($tags_array, $get_url = true) {
* @return mixed/string Tag ids * @return mixed/string Tag ids
*/ */
function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = 'module_condition', $query_prefix = '', $query_table = '', $meta = false, $childrens_ids = array(), $force_group_and_tag = false) { function tags_get_acl_tags($id_user, $id_group, $access = 'AR',
$return_mode = 'module_condition', $query_prefix = '',
$query_table = '', $meta = false, $childrens_ids = array(),
$force_group_and_tag = false) {
global $config; global $config;
@ -796,6 +799,10 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
if ($i == 0) if ($i == 0)
$condition .= ' ( '; $condition .= ' ( ';
// Group condition (The module belongs to an agent of the group X) // Group condition (The module belongs to an agent of the group X)
// Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition // Juanma (08/05/2014) Fix: Now group and tag is checked at the same time, before only tag was checked due to a bad condition
if (!array_key_exists(0, $acltags)) { if (!array_key_exists(0, $acltags)) {
@ -806,10 +813,20 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
//Avoid the user profiles with all group access. //Avoid the user profiles with all group access.
$group_condition = " 1 = 1 "; $group_condition = " 1 = 1 ";
} }
//When the acl is only group without tags
if (empty($group_tags)) {
$condition .= "($group_condition)\n";
}
else {
// 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 = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags)); $tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, implode(',',$group_tags));
$condition .= "($group_condition AND \n$tags_condition)\n"; $condition .= "($group_condition AND \n$tags_condition)\n";
}
$i++; $i++;
} }