Merge branch '2737-Optimización-de-tags-dev' of https://192.168.50.5:8081/artica/pandorafms into 2737-Optimización-de-tags-dev
This commit is contained in:
commit
8339eecacc
|
@ -327,6 +327,7 @@ $agents = agents_get_group_agents (array_keys ($groups));
|
|||
|
||||
$modules = db_get_all_rows_sql("SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo
|
||||
WHERE id_agente = " . $id_parent);
|
||||
if ($modules === false) $modules = array();
|
||||
|
||||
$modules_values = array();
|
||||
$modules_values[0] = __('Any');
|
||||
|
|
|
@ -734,7 +734,7 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
|||
if($has_secondary){
|
||||
$agent_condition = sprintf('((tagente.id_grupo = %d OR tasg.id_group = %d) %s)',$group_id,$group_id,$tag_join);
|
||||
} else {
|
||||
$agent_condition = sprintf('((tagente.id_grupo = %d %s)',$group_id,$tag_join);
|
||||
$agent_condition = sprintf('((tagente.id_grupo = %d %s))',$group_id,$tag_join);
|
||||
}
|
||||
$group_conditions[] = $agent_condition;
|
||||
} else {
|
||||
|
@ -757,67 +757,6 @@ function tags_get_acl_tags_module_condition($acltags, $modules_table = '') {
|
|||
return $condition;
|
||||
}
|
||||
|
||||
// The old function will be keeped to serve as reference of the changes done
|
||||
/**
|
||||
* Transform the acl_groups data into a SQL condition
|
||||
*
|
||||
* @param mixed acl_groups data calculated in tags_get_acl_tags function
|
||||
*
|
||||
* @return string SQL condition for tagente_module
|
||||
*/
|
||||
function tags_get_acl_tags_module_condition_old($acltags, $modules_table = '') {
|
||||
if (!empty($modules_table))
|
||||
$modules_table .= '.';
|
||||
|
||||
$condition = '';
|
||||
$group_conditions = array();
|
||||
|
||||
// The acltags array contains the groups with the acl propagation applied
|
||||
// after the changes done into the 'tags_get_user_groups_and_tags' function.
|
||||
foreach ($acltags as $group_id => $group_tags) {
|
||||
$tag_join = '';
|
||||
if (!empty($group_tags)) {
|
||||
$tag_join = sprintf('INNER JOIN ttag_module ttmc
|
||||
ON tamc.id_agente_modulo = ttmc.id_agente_modulo
|
||||
AND ttmc.id_tag IN (%s)',
|
||||
is_array($group_tags) ? implode(',', $group_tags) : $group_tags);
|
||||
}
|
||||
// FIXME: Not properly way to increse performance
|
||||
if(enterprise_hook('agents_is_using_secondary_groups')){
|
||||
$agent_condition = sprintf('SELECT tamc.id_agente_modulo
|
||||
FROM tagente_modulo tamc
|
||||
%s
|
||||
INNER JOIN tagente tac
|
||||
ON tamc.id_agente = tac.id_agente
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON tasg.id_agent = tac.id_agente
|
||||
WHERE (tac.id_grupo = %d OR tasg.id_group = %d)',
|
||||
$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);
|
||||
|
||||
$group_conditions[] = $sql_condition;
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!empty($group_conditions))
|
||||
$condition = implode(' OR ', $group_conditions);
|
||||
$condition = !empty($condition) ? "($condition)" : '';
|
||||
|
||||
return $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the acl_groups data into a SQL condition
|
||||
*
|
||||
|
@ -2146,7 +2085,9 @@ function tags_get_user_groups_and_tags ($id_user = false, $access = 'AR', $stric
|
|||
|
||||
$return = array();
|
||||
foreach ($acls as $acl) {
|
||||
$return[$acl["id_grupo"]] = implode(",",$acl["tags"][get_acl_column($access)]);
|
||||
$return[$acl["id_grupo"]] = isset($acl["tags"][get_acl_column($access)])
|
||||
? implode(",",$acl["tags"][get_acl_column($access)])
|
||||
: "";
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
|
|
@ -65,58 +65,6 @@ Array.prototype.in_array = function () {
|
|||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fill up select box with id "module" with modules after agent has been selected
|
||||
*
|
||||
* @param event that has been triggered
|
||||
* @param id_agent Agent ID that has been selected
|
||||
* @param selected Which module(s) have to be selected
|
||||
*/
|
||||
function agent_changed (event, id_agent, selected) {
|
||||
if (id_agent == undefined)
|
||||
id_agent = this.value;
|
||||
$('#module').attr ('disabled', 1);
|
||||
$('#module').empty ();
|
||||
$('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0));
|
||||
jQuery.post ('ajax.php',
|
||||
{"page": "operation/agentes/ver_agente",
|
||||
"get_agent_modules_json": 1,
|
||||
"id_agent": id_agent
|
||||
},
|
||||
function (data) {
|
||||
|
||||
$('#module').empty ();
|
||||
|
||||
if (typeof($(document).data('text_for_module')) != 'undefined') {
|
||||
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
|
||||
}
|
||||
else {
|
||||
if (typeof(data['any_text']) != 'undefined') {
|
||||
$('#module').append ($('<option></option>').html (data['any_text']).attr ("value", 0).prop('selected', true));
|
||||
}
|
||||
else {
|
||||
var anyText = $("#any_text").html(); //Trick for catch the translate text.
|
||||
|
||||
if (anyText == null) {
|
||||
anyText = 'Any';
|
||||
}
|
||||
|
||||
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
|
||||
}
|
||||
}
|
||||
jQuery.each (data, function (i, val) {
|
||||
s = js_html_entity_decode (val['nombre']);
|
||||
$('#module').append ($('<option></option>').html (s).attr ("value", val['id_agente_modulo']));
|
||||
$('#module').fadeIn ('normal');
|
||||
});
|
||||
if (selected != undefined)
|
||||
$('#module').attr ('value', selected);
|
||||
$('#module').removeAttr('disabled');
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Util for check is empty object
|
||||
*
|
||||
|
|
|
@ -720,7 +720,6 @@ if (is_ajax ()) {
|
|||
$id_agent = array_keys(
|
||||
agents_get_group_agents(
|
||||
array_keys (users_get_groups ()), $search, "none"));
|
||||
// TODO TAGS agents_get_modules
|
||||
$agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed, true, false, $tags);
|
||||
}
|
||||
// Restore db connection
|
||||
|
|
Loading…
Reference in New Issue