From a008c7486c4b543d1802d0813ba42bcbe86f90d8 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 14 Dec 2023 17:28:34 +0100 Subject: [PATCH 1/2] #12026 Fixed widget --- .../lib/Dashboard/Widgets/inventory.php | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/inventory.php b/pandora_console/include/lib/Dashboard/Widgets/inventory.php index a8fc01ee1c..8424d6cfbf 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/inventory.php +++ b/pandora_console/include/lib/Dashboard/Widgets/inventory.php @@ -177,6 +177,12 @@ class InventoryWidget extends Widget // Must be configured before using. $this->configurationRequired = false; + if (isset($this->values['inventoryModuleId']) + && $this->values['inventoryModuleId'] === 'basic' + && $this->values['agentId'] === 0 + ) { + $this->configurationRequired = true; + } } @@ -296,9 +302,12 @@ class InventoryWidget extends Widget ]; $fields = []; - array_unshift($fields, __('All')); + if (isset($values['inventoryModuleId']) === false) { + $values['inventoryModuleId'] = 0; + } + $inputs[] = [ 'label' => __('Module'), 'arguments' => [ @@ -316,31 +325,6 @@ class InventoryWidget extends Widget ], ]; - // Agent select. - if ($is_metaconsole === false) { - $agents = []; - $sql = 'SELECT id_agente, nombre FROM tagente'; - if ($inventory_id_group > 0) { - $sql .= ' WHERE id_grupo = '.$inventory_id_group; - } else { - $user_groups = implode(',', array_keys(users_get_groups($config['id_user']))); - - // Avoid errors if there are no groups. - if (empty($user_groups) === true) { - $user_groups = '"0"'; - } - - $sql .= ' WHERE id_grupo IN ('.$user_groups.')'; - } - - $result = db_get_all_rows_sql($sql); - if ($result) { - foreach ($result as $row) { - $agents[$row['id_agente']] = $row['nombre']; - } - } - } - // Date filter. if (is_metaconsole() === false) { $inputs[] = [ From 31acb0964a8a42ebf7b32d9b635818bc88cd6b7e Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 15 Jan 2024 11:18:31 +0100 Subject: [PATCH 2/2] #12026 Fixed configuration --- pandora_console/include/lib/Dashboard/Widgets/inventory.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/inventory.php b/pandora_console/include/lib/Dashboard/Widgets/inventory.php index 8424d6cfbf..657e67828e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/inventory.php +++ b/pandora_console/include/lib/Dashboard/Widgets/inventory.php @@ -177,10 +177,7 @@ class InventoryWidget extends Widget // Must be configured before using. $this->configurationRequired = false; - if (isset($this->values['inventoryModuleId']) - && $this->values['inventoryModuleId'] === 'basic' - && $this->values['agentId'] === 0 - ) { + if (isset($this->values['idGroup']) === false) { $this->configurationRequired = true; } }