Merge branch 'ent-12665-error-500-al-crear-un-custom-graph' into 'develop'

fix rerors selectors pandora_enterprise#12665

See merge request artica/pandorafms!6788
This commit is contained in:
Rafael Ameijeiras 2023-12-19 07:57:28 +00:00
commit 8cc159f19f
2 changed files with 29 additions and 7 deletions

View File

@ -236,17 +236,39 @@ if ($add_module === true) {
$id_modules $id_modules
); );
$id_agent_modules = db_get_all_rows_sql( $sql = sprintf(
'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')" 'SELECT id_agente_modulo
FROM tagente_modulo
WHERE id_agente IN (%s)
AND nombre IN ("%s")',
implode(',', $id_agents),
implode('","', $id_modules)
); );
$id_agent_modules = db_get_all_rows_sql($sql);
if (count($id_agent_modules) > 0 && $id_agent_modules != '') { if (count($id_agent_modules) > 0 && $id_agent_modules != '') {
$order = db_get_row_sql("SELECT `field_order` from tgraph_source WHERE id_graph=$id_graph ORDER BY `field_order` DESC"); $sql_order = sprintf(
'SELECT `field_order`
FROM tgraph_source
WHERE id_graph=%d
ORDER BY `field_order` DESC',
$id_graph
);
$order = db_get_row_sql($sql_order);
$order = $order['field_order']; $order = $order['field_order'];
foreach ($id_agent_modules as $id_agent_module) { foreach ($id_agent_modules as $id_agent_module) {
$order++; $order++;
$result = db_process_sql_insert('tgraph_source', ['id_graph' => $id_graph, 'id_agent_module' => $id_agent_module['id_agente_modulo'], 'weight' => $weight, 'field_order' => $order]); $result = db_process_sql_insert(
'tgraph_source',
[
'id_graph' => $id_graph,
'id_agent_module' => $id_agent_module['id_agente_modulo'],
'weight' => $weight,
'field_order' => $order,
]
);
} }
} else { } else {
$result = false; $result = false;

View File

@ -3857,11 +3857,11 @@ function get_modules_agents(
$modules = array_reduce( $modules = array_reduce(
$modules, $modules,
function ($carry, $item) use ($id_agents, $selection) { function ($carry, $item) use ($id_agents, $selection, $useName) {
if (count($id_agents) > 1 && (bool) $selection === true) { if (count($id_agents) > 1 && (bool) $selection === true) {
$carry[$item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre']; $carry[($useName === true) ? io_safe_output($item['nombre']) : $item['id_agente_modulo']] = $item['alias'].' » '.$item['nombre'];
} else { } else {
$carry[$item['id_agente_modulo']] = $item['nombre']; $carry[($useName === true) ? io_safe_output($item['nombre']) : $item['id_agente_modulo']] = $item['nombre'];
} }
return $carry; return $carry;