Fixed an error which causes a weird update counter

This commit is contained in:
Alejandro Gallardo Escobar 2015-07-07 17:38:24 +02:00
parent 8e8de1f706
commit 2f97ef3c36
1 changed files with 19 additions and 6 deletions

View File

@ -115,7 +115,10 @@ if ($update) {
$agents_ = array_keys(agents_get_group_agents($group_select, false, 'none')); $agents_ = array_keys(agents_get_group_agents($group_select, false, 'none'));
foreach ($agents_ as $id_agent) { foreach ($agents_ as $id_agent) {
$filter = array('id_agente' => $id_agent); $filter = array(
'id_agente' => $id_agent,
'delete_pending' => 0
);
$module_name = db_get_all_rows_filter('tagente_modulo', $filter, 'nombre'); $module_name = db_get_all_rows_filter('tagente_modulo', $filter, 'nombre');
if ($module_name === false) if ($module_name === false)
$module_name = array(); $module_name = array();
@ -136,9 +139,20 @@ if ($update) {
$modules_ = array(); $modules_ = array();
foreach ($modules_ as $module_) { foreach ($modules_ as $module_) {
$result = process_manage_edit ($module_, $agents_); $filter = array('id_agente' => $agent_);
$count++;
$success += (int)$result; if (!is_numeric($module_))
$filter['nombre'] = $module_;
else
$filter['id_agente_modulo'] = $module_;
$exists = (bool) db_get_value_filter('id_agente', 'tagente_modulo', $filter);
if ($exists) {
$result = process_manage_edit ($module_, $agent_);
$count++;
$success += (int)$result;
}
} }
} }
} }
@ -147,8 +161,7 @@ if ($update) {
__('Successfully updated') . "(" . $success . "/" . $count . ")", __('Successfully updated') . "(" . $success . "/" . $count . ")",
__('Could not be updated')); __('Could not be updated'));
$info = 'Modules: ' . json_encode($modules_) . $info = 'Modules: ' . json_encode($modules_) . ' Agents: ' . json_encode($agents_);
' Agents: ' . json_encode($agents_);
if ($success > 0) { if ($success > 0) {
db_pandora_audit("Massive management", "Edit module", false, false, $info); db_pandora_audit("Massive management", "Edit module", false, false, $info);
} }