wip reports alert actions

This commit is contained in:
Daniel Barbero Martin 2021-11-26 13:23:46 +01:00
parent 0b04ba44f2
commit be5fe18762
1 changed files with 29 additions and 20 deletions

View File

@ -3511,30 +3511,39 @@ function modules_get_agentmodule_mininterval_no_async($id_agent)
function get_same_modules($agents, $modules) function get_same_modules($agents, $modules)
{ {
$name_modules = modules_get_agentmodule_name_array(array_values($modules)); $name_modules = modules_get_agentmodule_name_array(array_values($modules));
$modules_to_report = [];
if ($modules != '') { $sql = sprintf(
foreach ($modules as $m) { 'SELECT id_agente_modulo as id
$module_name = $name_modules[$m]; FROM tagente_modulo
foreach ($agents as $a) { WHERE id_agente IN (%s)',
$module_in_agent = db_get_value_filter( implode(',', array_values($agents))
'id_agente_modulo', );
'tagente_modulo',
[ hd('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
'id_agente' => $a, hd($sql);
'nombre' => $module_name,
] $all = db_get_all_rows_sql($sql);
);
if ($module_in_agent) { if ($all === false) {
$modules_to_report[] = $module_in_agent; $all = [];
}
}
}
} }
$modules_to_report = array_merge($modules_to_report, $modules); $all = array_reduce(
$all,
function ($carry, $item) use ($name_modules) {
if (isset($name_modules[$item['id']]) === true) {
$carry[$item['id']] = $item['id'];
}
return $carry;
},
[]
);
$modules_to_report = array_merge($all, $modules);
$modules_to_report = array_unique($modules_to_report); $modules_to_report = array_unique($modules_to_report);
return $modules_to_report; return $all;
} }