Merge branch 'ent-2836-Operaciones-masivas-filtrado-de-modulos-por-tag' into 'develop'
Fixed bug in filtered modules by tag See merge request artica/pandorafms!2181 Former-commit-id: f313f0cab032ccc8329933a641db8c541b682474
This commit is contained in:
commit
55486e7b93
|
@ -3102,7 +3102,7 @@ function select_agents_for_module_group(
|
||||||
'AND',
|
'AND',
|
||||||
'tagente_modulo',
|
'tagente_modulo',
|
||||||
true,
|
true,
|
||||||
[],
|
$filter['tags'],
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
$sql_tags_inner = 'INNER JOIN ttag_module
|
$sql_tags_inner = 'INNER JOIN ttag_module
|
||||||
|
|
|
@ -748,7 +748,7 @@ function tags_get_acl_tags(
|
||||||
$id_user = $config['id_user'];
|
$id_user = $config['id_user'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_user_admin($id_user)) {
|
if (is_user_admin($id_user) && empty($childrens_ids)) {
|
||||||
switch ($return_mode) {
|
switch ($return_mode) {
|
||||||
case 'data':
|
case 'data':
|
||||||
return [];
|
return [];
|
||||||
|
@ -797,7 +797,8 @@ function tags_get_acl_tags(
|
||||||
// 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(
|
$condition = tags_get_acl_tags_module_condition(
|
||||||
$acltags,
|
$acltags,
|
||||||
$query_table
|
$query_table,
|
||||||
|
empty($childrens_ids) ? [] : $childrens_ids
|
||||||
);
|
);
|
||||||
if (!empty($condition)) {
|
if (!empty($condition)) {
|
||||||
return " $query_prefix ".$condition;
|
return " $query_prefix ".$condition;
|
||||||
|
@ -825,7 +826,7 @@ function tags_get_acl_tags(
|
||||||
*
|
*
|
||||||
* @return string SQL condition for tagente_module
|
* @return string SQL condition for tagente_module
|
||||||
*/
|
*/
|
||||||
function tags_get_acl_tags_module_condition($acltags, $modules_table='')
|
function tags_get_acl_tags_module_condition($acltags, $modules_table='', $force_tags=[])
|
||||||
{
|
{
|
||||||
if (!empty($modules_table)) {
|
if (!empty($modules_table)) {
|
||||||
$modules_table .= '.';
|
$modules_table .= '.';
|
||||||
|
@ -839,6 +840,17 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='')
|
||||||
// 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) {
|
||||||
|
if (empty($group_tags)) {
|
||||||
|
$group_tags = [];
|
||||||
|
if (!empty($force_tags)) {
|
||||||
|
$group_tags = $force_tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($group_tags)) {
|
||||||
|
$group_tags = array_intersect($force_tags, $group_tags);
|
||||||
|
}
|
||||||
|
|
||||||
$tag_join = '';
|
$tag_join = '';
|
||||||
if (!empty($group_tags)) {
|
if (!empty($group_tags)) {
|
||||||
$tag_join = sprintf('AND ttag_module.id_tag IN (%s)', is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
|
$tag_join = sprintf('AND ttag_module.id_tag IN (%s)', is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
|
||||||
|
@ -849,7 +861,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table='')
|
||||||
}
|
}
|
||||||
|
|
||||||
$group_conditions[] = $agent_condition;
|
$group_conditions[] = $agent_condition;
|
||||||
} else {
|
} else if (!empty($force_tags)) {
|
||||||
$without_tags[] = $group_id;
|
$without_tags[] = $group_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,6 +503,14 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
|
||||||
selection_mode = "common";
|
selection_mode = "common";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tags_selected = [];
|
||||||
|
|
||||||
|
var tags_to_search = $("#tags").val();
|
||||||
|
if (tags_to_search != null) {
|
||||||
|
if (tags_to_search[0] != -1) {
|
||||||
|
tags_selected = tags_to_search;
|
||||||
|
}
|
||||||
|
}
|
||||||
jQuery.post(
|
jQuery.post(
|
||||||
"ajax.php",
|
"ajax.php",
|
||||||
{
|
{
|
||||||
|
@ -510,7 +518,8 @@ function module_changed_by_multiple_modules(event, id_module, selected) {
|
||||||
get_agents_json_for_multiple_modules: 1,
|
get_agents_json_for_multiple_modules: 1,
|
||||||
status_module: status_module,
|
status_module: status_module,
|
||||||
"module_name[]": idModules,
|
"module_name[]": idModules,
|
||||||
selection_mode: selection_mode
|
selection_mode: selection_mode,
|
||||||
|
tags: tags_selected
|
||||||
},
|
},
|
||||||
function(data) {
|
function(data) {
|
||||||
$("#agents").append(
|
$("#agents").append(
|
||||||
|
|
|
@ -177,11 +177,14 @@ if (is_ajax()) {
|
||||||
$nameModules = get_parameter('module_name');
|
$nameModules = get_parameter('module_name');
|
||||||
$selection_mode = get_parameter('selection_mode', 'common') == 'all';
|
$selection_mode = get_parameter('selection_mode', 'common') == 'all';
|
||||||
$status_modulo = (int) get_parameter('status_module', -1);
|
$status_modulo = (int) get_parameter('status_module', -1);
|
||||||
|
$tags_selected = (array) get_parameter('tags', []);
|
||||||
$names = select_agents_for_module_group(
|
$names = select_agents_for_module_group(
|
||||||
$nameModules,
|
$nameModules,
|
||||||
$selection_mode,
|
$selection_mode,
|
||||||
['status' => $status_modulo],
|
[
|
||||||
|
'status' => $status_modulo,
|
||||||
|
'tags' => $tags_selected,
|
||||||
|
],
|
||||||
'AW'
|
'AW'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue