Merge branch '2040-Tags-en-operaciones-masivas' into 'develop'

fixed bug on bulk delete and bulk update module operation

See merge request artica/pandorafms!1613
This commit is contained in:
vgilc 2018-09-28 11:05:34 +02:00
commit 2dac09435a
4 changed files with 22 additions and 15 deletions

View File

@ -47,17 +47,21 @@ $update = (bool) get_parameter_post ('update');
if ($update) { if ($update) {
$agents_ = ''; $agents_ = '';
if ($selection_mode == 'modules') { if ($selection_mode == 'modules') {
$agents_ = array();
$force = get_parameter('force_type', false); $force = get_parameter('force_type', false);
if ($agents_select == false) { if ($agents_select == false) {
$agents_select = array(); $agents_select = array();
$agents_ = array();
} }
foreach ($agents_select as $agent_name) { foreach ($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id($agent_name); $agents_[] = agents_get_agent_id($agent_name);
} }
$modules_ = $module_name; $modules_ = $module_name;
} }
else if ($selection_mode == 'agents') { else if ($selection_mode == 'agents') {
$force = get_parameter('force_group', false); $force = get_parameter('force_group', false);
@ -75,6 +79,7 @@ if ($update) {
// If the option to select all of one group or module type is checked // If the option to select all of one group or module type is checked
if ($force) { if ($force) {
if ($force == 'type') { if ($force == 'type') {
$type_condition = ''; $type_condition = '';
if ($module_type != 0) if ($module_type != 0)
$type_condition = "AND tam.id_tipo_modulo = $module_type"; $type_condition = "AND tam.id_tipo_modulo = $module_type";
@ -141,12 +146,11 @@ if ($update) {
else { else {
// Standard procedure // Standard procedure
foreach ($agents_ as $agent_) { foreach ($agents_ as $agent_) {
if ($modules_ == false) if ($modules_ == false)
$modules_ = array(); $modules_ = array();
foreach ($modules_ as $module_) { foreach ($modules_ as $module_) {
$result = process_manage_edit ($module_, $agent_, $modules_selection_mode); $result = process_manage_edit ($module_, $agent_, $modules_selection_mode);
$count++; $count++;
$success += (int)$result; $success += (int)$result;
@ -331,6 +335,7 @@ $table->data['form_modules_2'][2] .= html_print_select (
'all' => __('Show all agents')), 'all' => __('Show all agents')),
'agents_selection_mode', 'agents_selection_mode',
'common', false, '', '', true); 'common', false, '', '', true);
$table->data['form_modules_2'][3] = html_print_select (array(), 'agents[]', $table->data['form_modules_2'][3] = html_print_select (array(), 'agents[]',
$agents_select, false, __('None'), 0, true, true, false); $agents_select, false, __('None'), 0, true, true, false);
@ -1540,12 +1545,14 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu
$update_tags = get_parameter('id_tag', false); $update_tags = get_parameter('id_tag', false);
if (array_search(0, $agents_select) !== false) { if (array_search(0, $agents_select) !== false) {
//Apply at All agents. //Apply at All agents.
$modules = db_get_all_rows_filter ('tagente_modulo', $modules = db_get_all_rows_filter ('tagente_modulo',
$filter_modules, $filter_modules,
array ('id_agente_modulo')); array ('id_agente_modulo'));
} }
else { else {
if ($module_name == "0") { if ($module_name == "0") {
//Any module //Any module
$modules = db_get_all_rows_filter ('tagente_modulo', $modules = db_get_all_rows_filter ('tagente_modulo',
@ -1559,7 +1566,8 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu
array ('id_agente_modulo')); array ('id_agente_modulo'));
} }
} }
if ($modules === false) if ($modules === false)
return false; return false;
@ -1575,16 +1583,16 @@ function process_manage_edit ($module_name, $agents_select = null, $module_statu
} }
$modules = $modules_to_delete; $modules = $modules_to_delete;
} }
foreach ($modules as $module) { foreach ($modules as $module) {
$result = modules_update_agent_module( $result = modules_update_agent_module(
$module['id_agente_modulo'], $values, true, $update_tags); $module['id_agente_modulo'], $values, true, $update_tags);
if (is_error($result)) {
if (is_error($result))
return false; return false;
}
} }
return true; return true;

View File

@ -441,7 +441,7 @@ function modules_update_agent_module ($id, $values,
} }
$result = @db_process_sql_update ('tagente_modulo', $values, $where); $result = @db_process_sql_update ('tagente_modulo', $values, $where);
if ($result == false) { if ($result == false) {
if ($result_disable === ERR_GENERIC ){ if ($result_disable === ERR_GENERIC ){
return ERR_DB; return ERR_DB;

View File

@ -529,7 +529,7 @@ function module_changed_by_multiple_modules (event, id_module, selected) {
jQuery.each (data, function (i, val) { jQuery.each (data, function (i, val) {
s = js_html_entity_decode(val); s = js_html_entity_decode(val);
$('#agents') $('#agents')
.append ($('<option></option>').html (s).attr ("value", val)); .append ($('<option></option>').html (s).attr ("value", i));
$('#agents').fadeIn ('normal'); $('#agents').fadeIn ('normal');
}); });

View File

@ -207,7 +207,7 @@ if (is_ajax ()) {
$groups = users_get_groups ($config["id_user"], "AW", false); $groups = users_get_groups ($config["id_user"], "AW", false);
$group_id_list = ($groups ? join(",",array_keys($groups)):"0"); $group_id_list = ($groups ? join(",",array_keys($groups)):"0");
$sql = 'SELECT DISTINCT(t1.alias) as name $sql = 'SELECT DISTINCT(t1.nombre) as name, t1.alias
FROM tagente t1, tagente_modulo t2 FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente WHERE t1.id_agente = t2.id_agente
AND t1.id_grupo IN (' . $group_id_list .') AND t1.id_grupo IN (' . $group_id_list .')
@ -254,10 +254,9 @@ if (is_ajax ()) {
if ($nameAgents == false) if ($nameAgents == false)
$nameAgents = array(); $nameAgents = array();
foreach ($nameAgents as $nameAgent) { foreach ($nameAgents as $nameAgent)
$names[] = io_safe_output($nameAgent['name']); $names[$nameAgent['name']] = io_safe_output($nameAgent['alias']);
}
echo json_encode($names); echo json_encode($names);
return; return;
} }