mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
Fixed the ajax of get modules when the user have profiles with tags and without tags.
This commit is contained in:
parent
c7b3104224
commit
b72af65bd0
@ -1161,9 +1161,11 @@ function agents_get_modules ($id_agent = null, $details = false,
|
|||||||
|
|
||||||
//$where .= " AND id_policy_module = 0 ";
|
//$where .= " AND id_policy_module = 0 ";
|
||||||
|
|
||||||
$where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR', 'module_condition', 'AND', 'tagente_modulo');
|
$where_tags = tags_get_acl_tags($config['id_user'], $id_groups, 'AR',
|
||||||
|
'module_condition', 'AND', 'tagente_modulo', false, array(),
|
||||||
|
true);
|
||||||
|
|
||||||
$where .= $where_tags;
|
$where .= "\n\n" . $where_tags;
|
||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
@ -1189,6 +1191,7 @@ function agents_get_modules ($id_agent = null, $details = false,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = db_get_all_rows_sql ($sql);
|
$result = db_get_all_rows_sql ($sql);
|
||||||
|
|
||||||
if (empty ($result)) {
|
if (empty ($result)) {
|
||||||
|
@ -596,7 +596,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;
|
||||||
|
|
||||||
@ -635,6 +638,7 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||||||
|
|
||||||
$acltags = tags_get_user_module_and_tags($id_user, $access);
|
$acltags = tags_get_user_module_and_tags($id_user, $access);
|
||||||
|
|
||||||
|
|
||||||
// Delete the groups without tag restrictions from the acl tags array if $force_group_and_tag == false
|
// Delete the groups without tag restrictions from the acl tags array if $force_group_and_tag == false
|
||||||
// Delete the groups that aren't in the received groups id
|
// Delete the groups that aren't in the received groups id
|
||||||
$acltags_aux = array();
|
$acltags_aux = array();
|
||||||
@ -660,7 +664,9 @@ function tags_get_acl_tags($id_user, $id_group, $access = 'AR', $return_mode = '
|
|||||||
break;
|
break;
|
||||||
case 'module_condition':
|
case 'module_condition':
|
||||||
// Return the condition of the tags for tagente_modulo table
|
// Return the condition of the tags for tagente_modulo table
|
||||||
$condition = tags_get_acl_tags_module_condition($acltags, $query_table, true);
|
|
||||||
|
$condition = tags_get_acl_tags_module_condition($acltags,
|
||||||
|
$query_table);
|
||||||
if (!empty($condition)) {
|
if (!empty($condition)) {
|
||||||
return " $query_prefix " . $condition;
|
return " $query_prefix " . $condition;
|
||||||
}
|
}
|
||||||
@ -701,7 +707,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
|||||||
|
|
||||||
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
|
// Fix: Wrap SQL expression with "()" to avoid bad SQL sintax that makes Pandora retrieve all modules without taking care of id_agent => id_agent = X AND (sql_tag_expression)
|
||||||
if ($i == 0)
|
if ($i == 0)
|
||||||
$condition .= ' ( ';
|
$condition .= ' ( ' . "\n";
|
||||||
|
|
||||||
// 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
|
||||||
@ -727,7 +733,12 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
|||||||
// 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, $group_tags_query);
|
$tags_condition = sprintf('%sid_agente_modulo IN (SELECT id_agente_modulo FROM ttag_module WHERE id_tag IN (%s))', $modules_table, $group_tags_query);
|
||||||
|
|
||||||
$condition .= "($group_condition AND \n$tags_condition)\n";
|
$condition .=
|
||||||
|
" ( \n" .
|
||||||
|
" $group_condition \n" .
|
||||||
|
" AND \n" .
|
||||||
|
" $tags_condition \n" .
|
||||||
|
" )\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -2227,10 +2238,11 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
|||||||
if (!empty($all_groups))
|
if (!empty($all_groups))
|
||||||
$all_group_ids = array_keys($all_groups);
|
$all_group_ids = array_keys($all_groups);
|
||||||
|
|
||||||
|
|
||||||
$tags_and_groups_aux = array();
|
$tags_and_groups_aux = array();
|
||||||
foreach ($tags_and_groups as $data) {
|
foreach ($tags_and_groups as $data) {
|
||||||
// All group
|
// All group
|
||||||
if ($data['id_grupo'] == 0) {
|
if ($data['id_grupo'] === 0) {
|
||||||
// All group with empty tags. All groups without tags permission!
|
// All group with empty tags. All groups without tags permission!
|
||||||
if (empty($data['tags'])) {
|
if (empty($data['tags'])) {
|
||||||
foreach ($all_group_ids as $group_id) {
|
foreach ($all_group_ids as $group_id) {
|
||||||
@ -2257,10 +2269,12 @@ function tags_get_user_module_and_tags ($id_user = false, $access = 'AR', $stric
|
|||||||
$tags_and_groups = $tags_and_groups_aux;
|
$tags_and_groups = $tags_and_groups_aux;
|
||||||
unset($tags_and_groups_aux);
|
unset($tags_and_groups_aux);
|
||||||
|
|
||||||
|
|
||||||
foreach ($tags_and_groups as $group_tag) {
|
foreach ($tags_and_groups as $group_tag) {
|
||||||
__add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']);
|
__add_acltags($acltags, $group_tag['id_grupo'], $group_tag['tags']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $acltags;
|
return $acltags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user