mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
Fix recursion on networkmap nodes
This commit is contained in:
parent
91cd12c715
commit
90ac62c0cc
@ -55,6 +55,7 @@ if (is_ajax()) {
|
|||||||
$process_migration = (bool) get_parameter('process_migration', false);
|
$process_migration = (bool) get_parameter('process_migration', false);
|
||||||
$get_agent_info = (bool) get_parameter('get_agent_info', false);
|
$get_agent_info = (bool) get_parameter('get_agent_info', false);
|
||||||
$update_node = (bool) get_parameter('update_node', false);
|
$update_node = (bool) get_parameter('update_node', false);
|
||||||
|
$get_agents_in_group = (bool) get_parameter('get_agents_in_group', false);
|
||||||
|
|
||||||
if ($update_node) {
|
if ($update_node) {
|
||||||
$node_json = io_safe_output(get_parameter('node', ''));
|
$node_json = io_safe_output(get_parameter('node', ''));
|
||||||
@ -80,6 +81,65 @@ if (is_ajax()) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($get_agents_in_group) {
|
||||||
|
$id = (int) get_parameter('id', 0);
|
||||||
|
$group = (int) get_parameter('group', -1);
|
||||||
|
$group_recursion = (int) get_parameter('group_recursion', 0);
|
||||||
|
|
||||||
|
$return = [];
|
||||||
|
$return['correct'] = false;
|
||||||
|
|
||||||
|
if ($group != -1) {
|
||||||
|
$where_id_agente = ' 1=1 ';
|
||||||
|
|
||||||
|
$agents_in_networkmap = db_get_all_rows_filter(
|
||||||
|
'titem',
|
||||||
|
[
|
||||||
|
'id_map' => $id,
|
||||||
|
'deleted' => 0,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if ($agents_in_networkmap !== false) {
|
||||||
|
$ids = [];
|
||||||
|
foreach ($agents_in_networkmap as $agent) {
|
||||||
|
if ($agent['type'] == 0) {
|
||||||
|
$ids[] = $agent['source_data'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($ids) === false) {
|
||||||
|
$where_id_agente = 'AND id_agente NOT IN ('.implode(',', $ids).')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($group_recursion !== 0) {
|
||||||
|
$group_tree = groups_get_children_ids($group);
|
||||||
|
$group = implode(',', $group_tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT id_agente, alias
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_grupo IN ('.$group.') AND '.$where_id_agente.'
|
||||||
|
ORDER BY alias ASC';
|
||||||
|
|
||||||
|
$agents = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
|
if ($agents !== false) {
|
||||||
|
$return['agents'] = [];
|
||||||
|
foreach ($agents as $agent) {
|
||||||
|
$return['agents'][$agent['id_agente']] = $agent['alias'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$return['correct'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($return);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module_get_status) {
|
if ($module_get_status) {
|
||||||
$id = (int) get_parameter('id', 0);
|
$id = (int) get_parameter('id', 0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user