From 1ba90d0c60ca127dca322ad42bc8dfb2e19bb6ee Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Mon, 23 Sep 2024 12:15:25 +0000 Subject: [PATCH 1/2] feat(multisearch): add option to ungroup result --- plugins/language/en_GB/en_GB.txt | 1 + plugins/language/fr_FR/fr_FR.txt | 1 + .../ms_multi_search/ms_multi_search.php | 18 +++++++++++++++++- require/search/Search.php | 7 +++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/plugins/language/en_GB/en_GB.txt b/plugins/language/en_GB/en_GB.txt index cfa713b76..d75abff46 100755 --- a/plugins/language/en_GB/en_GB.txt +++ b/plugins/language/en_GB/en_GB.txt @@ -1886,6 +1886,7 @@ 9930 DNS 9940 Is allowed to manage saved searches +9941 Ungroup the result 9950 Notifications 9951 Please check that the notification configuration has been set correctly, otherwise sending reports through notifications will not work diff --git a/plugins/language/fr_FR/fr_FR.txt b/plugins/language/fr_FR/fr_FR.txt index 9eae7bb4b..8f812494d 100644 --- a/plugins/language/fr_FR/fr_FR.txt +++ b/plugins/language/fr_FR/fr_FR.txt @@ -1881,6 +1881,7 @@ 9930 DNS 9940 Est autorisé à gérer les recherches sauvegardées +9941 Dégrouper le résultat 9950 Notifications 9951 Veuillez vérifier que les notifications ont été correctement configurées pour que l'envoi des rapports fonctionne diff --git a/plugins/main_sections/ms_multi_search/ms_multi_search.php b/plugins/main_sections/ms_multi_search/ms_multi_search.php index 1fd61b8b7..90bb1597a 100644 --- a/plugins/main_sections/ms_multi_search/ms_multi_search.php +++ b/plugins/main_sections/ms_multi_search/ms_multi_search.php @@ -289,11 +289,20 @@ } if(!empty($_SESSION['OCS']['multi_search'])){ + $checked = ""; + + if (isset($protectedPost["groupby_search"])) { + $checked = "checked"; + } + ?>
+
+ >g(9941) ?> +

@@ -322,10 +331,17 @@ if((isset($protectedPost['search_ok']) || isset($protectedGet['prov']) || isset($protectedGet['fields'])) && $isValid && !isset($protectedPost['table_select']) && !isset($protectedPost['columns_select'])){ unset($_SESSION['OCS']['SEARCH_SQL_GROUP']); + + $groupby = true; + + if (isset($protectedPost["groupby_search"])) { + $groupby = false; + } + /** * Generate Search fields */ - $search->generateSearchQuery($_SESSION['OCS']['multi_search']); + $search->generateSearchQuery($_SESSION['OCS']['multi_search'], $groupby); $sql = $search->baseQuery.$search->searchQuery.$search->columnsQueryConditions; $_SESSION['OCS']['multi_search_query'] = $sql; diff --git a/require/search/Search.php b/require/search/Search.php index f44442b7c..4864d342c 100644 --- a/require/search/Search.php +++ b/require/search/Search.php @@ -318,7 +318,7 @@ public function getFieldUniqId($uniqid, $tableName) * @param Array $sessData * @return void */ - public function generateSearchQuery($sessData){ + public function generateSearchQuery($sessData, $groupby = true){ new AccountinfoSearch(); $this->pushBaseQueryForTable("hardware", null); @@ -579,7 +579,10 @@ public function generateSearchQuery($sessData){ $this->columnsQueryConditions .= " AND " . $lockResult; } - $this->columnsQueryConditions .= " GROUP BY hardware.id"; + if ($groupby) { + $this->columnsQueryConditions .= " GROUP BY hardware.id"; + } + $this->baseQuery = substr($this->baseQuery, 0, -1); } From 3782b9f2c146f0252ede54fb9c3f6afd498e8bc3 Mon Sep 17 00:00:00 2001 From: Lea9250 <63054344+Lea9250@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:32:32 +0200 Subject: [PATCH 2/2] refactor(language): translation update --- plugins/language/en_GB/en_GB.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/language/en_GB/en_GB.txt b/plugins/language/en_GB/en_GB.txt index d75abff46..e7171312d 100755 --- a/plugins/language/en_GB/en_GB.txt +++ b/plugins/language/en_GB/en_GB.txt @@ -1886,7 +1886,7 @@ 9930 DNS 9940 Is allowed to manage saved searches -9941 Ungroup the result +9941 Ungroup results 9950 Notifications 9951 Please check that the notification configuration has been set correctly, otherwise sending reports through notifications will not work @@ -1921,4 +1921,4 @@ 9990 Download SNMP Subnets List 9991 Generate SNMP files -10000 Failed to update account info fields: quotes are not allowed in administrative values \ No newline at end of file +10000 Failed to update account info fields: quotes are not allowed in administrative values