From 17a9d6020f10c2f42664901ac2d83e06df36ef25 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 5 Apr 2023 12:52:44 +0200 Subject: [PATCH 1/2] #10864 Solution conflict files removed --- .../godmode/agentes/inventory_manager.php | 3 +- .../include/functions_inventory.php | 6 ++- .../operation/agentes/agent_inventory.php | 1 - .../operation/agentes/ver_agente.php | 42 +++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pandora_console/godmode/agentes/inventory_manager.php b/pandora_console/godmode/agentes/inventory_manager.php index 4b6a53df47..77feece220 100644 --- a/pandora_console/godmode/agentes/inventory_manager.php +++ b/pandora_console/godmode/agentes/inventory_manager.php @@ -237,8 +237,9 @@ if (db_get_num_rows($sql) == 0) { $table->head[5] = __('Actions'); $table->align = []; $table->align[5] = 'left'; - + $i = 0; foreach ($result as $row) { + $table->cellclass[$i++][5] = 'table_action_buttons'; $data = []; $sql = sprintf('SELECT id_policy FROM tpolicy_modules_inventory WHERE id = %d', $row['id_policy_module_inventory']); diff --git a/pandora_console/include/functions_inventory.php b/pandora_console/include/functions_inventory.php index 0a8c31c512..dc0c23a31c 100644 --- a/pandora_console/include/functions_inventory.php +++ b/pandora_console/include/functions_inventory.php @@ -756,8 +756,10 @@ function inventory_get_datatable( foreach ($rows as $row) { $data_rows = explode(PHP_EOL, $row['data']); foreach ($data_rows as $data_key => $data_value) { - $row['data'] = $data_value; - $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; + if (empty($data_value) === false) { + $row['data'] = $data_value; + $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row; + } } } diff --git a/pandora_console/operation/agentes/agent_inventory.php b/pandora_console/operation/agentes/agent_inventory.php index 7e99ec84f5..71dfb3bebc 100644 --- a/pandora_console/operation/agentes/agent_inventory.php +++ b/pandora_console/operation/agentes/agent_inventory.php @@ -219,7 +219,6 @@ foreach ($rows as $row) { if ($idModuleInventory != $row['id_module_inventory']) { if (isset($table) === true && $rowTable >= 1) { - html_print_table($table); unset($table); $rowTable = 1; $printedTables++; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index ad7977c9f4..2946f2ea70 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -30,7 +30,7 @@ use PandoraFMS\Enterprise\Metaconsole\Node; global $config; -require_once 'include/functions_gis.php'; +require_once $config['homedir'].'/include/functions_gis.php'; require_once $config['homedir'].'/include/functions_agents.php'; require_once $config['homedir'].'/include/functions_groups.php'; require_once $config['homedir'].'/include/functions_modules.php'; @@ -1442,22 +1442,13 @@ $alerttab['active'] = ($tab === 'alert'); // Inventory. $inventoryCount = db_get_num_rows('SELECT id_agent_module_inventory FROM tagent_module_inventory WHERE id_agente = '.$agent['id_agente']); -$inventorytab['text'] = ''.html_print_image( - 'images/hardware-software-component@svg.svg', - true, - [ - 'class' => 'main_menu_icon invert_filter', - 'title' => __('Inventory'), - ] -).''; -if ($tab == 'inventory') { - $inventorytab['active'] = true; -} else { - $inventorytab['active'] = false; +$inventorytab = enterprise_hook('inventory_tab'); + +if ($inventorytab === ENTERPRISE_NOT_HOOK || $inventoryCount === 0) { + $inventorytab = ''; } - // Collection. if ((int) $config['license_nms'] !== 1) { $collectiontab = enterprise_hook('collection_tab'); @@ -1477,12 +1468,13 @@ if ($policyTab === ENTERPRISE_NOT_HOOK) { // Omnishell. -$tasks = count_tasks_agent($id_agente); - -if ($tasks === true) { - $omnishellTab = enterprise_hook('omnishell_tab'); - if ($omnishellTab == -1) { - $omnishellTab = ''; +if (function_exists('count_tasks_agent')) { + $tasks = count_tasks_agent($id_agente); + if ($tasks === true) { + $omnishellTab = enterprise_hook('omnishell_tab'); + if ($omnishellTab == -1) { + $omnishellTab = ''; + } } } @@ -1587,7 +1579,7 @@ if (enterprise_installed() === true && (bool) $config['log_collector'] === true) $log_viewer_tab['text'] = html_print_menu_button( [ 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=log_viewer&id_agente='.$id_agente, - 'image' => 'images/gm_log.png', + 'image' => 'images/gm_log@svg.svg', 'title' => __('Log Viewer'), ], true @@ -1917,7 +1909,7 @@ switch ($tab) { if ((bool) $config['pure'] === false) { ui_print_standard_header( - __('Agent main view'), + __('Agent main view').' ( '.strtolower(agents_get_alias($id_agente)).' )', $icon, false, ($help_header ?? ''), @@ -1936,6 +1928,12 @@ if ((bool) $config['pure'] === false) { 'link' => '', 'label' => $tab_name, ], + ], + [ + 'id_element' => $id_agente, + 'url' => 'operation/agentes/ver_agente&id_agente='.$id_agente, + 'label' => agents_get_alias($id_agente), + 'section' => 'Agents', ] ); } From a0ae7327c7d055bb6826f90459cf8bcdc43b3ba9 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 10 Apr 2023 09:23:40 +0200 Subject: [PATCH 2/2] Conflict solution inventory --- .../operation/agentes/agent_inventory.php | 14 +++++++------- .../operation/agentes/ver_agente.php | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/pandora_console/operation/agentes/agent_inventory.php b/pandora_console/operation/agentes/agent_inventory.php index 71dfb3bebc..1d692bfd41 100644 --- a/pandora_console/operation/agentes/agent_inventory.php +++ b/pandora_console/operation/agentes/agent_inventory.php @@ -218,7 +218,8 @@ foreach ($rows as $row) { } if ($idModuleInventory != $row['id_module_inventory']) { - if (isset($table) === true && $rowTable >= 1) { + if (isset($table) === true && $rowTable > 1) { + html_print_table($table); unset($table); $rowTable = 1; $printedTables++; @@ -309,17 +310,16 @@ foreach ($rows as $row) { $rowTable++; } - if ($iterator1 > 5) { - // PRINT COUNT TOTAL. - $table->data[$rowTable][0] = ''.__('Total').': '.$iterator1; - $rowTable++; - } + // PRINT COUNT TOTAL. + $table->colspan[$rowTable][0] = 10; + $table->data[$rowTable][0] = ''.__('Total').': '.$iterator1; + $rowTable++; } $idModuleInventory = $row['id_module_inventory']; } -if (isset($table) === true && $rowTable >= 1) { +if (isset($table) === true && $rowTable > 1) { html_print_table($table); $printedTables++; } diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 2946f2ea70..19ac249753 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1443,10 +1443,21 @@ $alerttab['active'] = ($tab === 'alert'); // Inventory. $inventoryCount = db_get_num_rows('SELECT id_agent_module_inventory FROM tagent_module_inventory WHERE id_agente = '.$agent['id_agente']); -$inventorytab = enterprise_hook('inventory_tab'); +if ($inventoryCount > 0) { + $inventorytab['text'] = html_print_menu_button( + [ + 'href' => 'index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=inventory&id_agente='.$id_agente, + 'image' => 'images/hardware-software-component@svg.svg', + 'title' => __('Inventory'), + ], + true + ); -if ($inventorytab === ENTERPRISE_NOT_HOOK || $inventoryCount === 0) { - $inventorytab = ''; + if ($tab === 'inventory') { + $inventorytab['active'] = true; + } else { + $inventorytab['active'] = false; + } } // Collection.