From 33e6ee5b009f0887a1d4058cac0a2a190b097c4f Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Mon, 5 Oct 2020 10:52:38 +0200
Subject: [PATCH] FEAT #13271 TIME 0:15 control empty admin_search
 configuration

---
 src/app/search/controllers/SearchController.php | 3 +++
 src/lang/lang-en.json                           | 3 ++-
 src/lang/lang-fr.json                           | 3 ++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/app/search/controllers/SearchController.php b/src/app/search/controllers/SearchController.php
index 0d2ebaea2b4..a5a644e287d 100644
--- a/src/app/search/controllers/SearchController.php
+++ b/src/app/search/controllers/SearchController.php
@@ -145,6 +145,9 @@ class SearchController
         $order .= 'END';
 
         $adminSearch   = ConfigurationModel::getByPrivilege(['privilege' => 'admin_search', 'select' => ['value']]);
+        if (empty($adminSearch)) {
+            return $response->withStatus(400)->withJson(['errors' => 'no admin_search configuration found', 'lang' => 'noAdminSearchConfiguration']);
+        }
         $configuration = json_decode($adminSearch['value'], true);
         $listDisplay   = $configuration['listDisplay']['subInfos'];
 
diff --git a/src/lang/lang-en.json b/src/lang/lang-en.json
index 210ea88a908..69b899a4a8a 100644
--- a/src/lang/lang-en.json
+++ b/src/lang/lang-en.json
@@ -2033,5 +2033,6 @@
     "searchInAttachmentsInfo" : "Indicates that the search is done on mails and attachments.",
     "fulltext": "Fulltext",
     "searchFulltextInfo" : "\" \": To search on a group of words (\"route nationale\" finds the entire expression route nationale)<br>&nbsp;~: To perform an approximate search (vite~ find vote, vite)",
-    "criteriaOverQuickSearch" : "The search criteria are cumulative on the quick search"
+    "criteriaOverQuickSearch" : "The search criteria are cumulative on the quick search",
+    "noAdminSearchConfiguration": "Non administration configuration found"
 }
diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json
index dd33009fa8c..a6914cc78eb 100644
--- a/src/lang/lang-fr.json
+++ b/src/lang/lang-fr.json
@@ -2049,5 +2049,6 @@
     "searchFulltextInfo" : "\" \" : Pour effectuer une recherche sur un groupe de mots (\"route nationale\" trouve l'expression entière route nationale)<br>&nbsp;~ : Pour effectuer une recherche approximative (vite~ trouve vote, vite)",
     "criteriaOverQuickSearch" : "Les critères de recherche se cumulent sur la recherche rapide",
     "manualSearchInfo" : "Vous pouvez laisser le terme dans le champ sans sélectionner de valeur pour la recherche.",
-    "groupSign" : "Groupe du signataire"
+    "groupSign" : "Groupe du signataire",
+    "noAdminSearchConfiguration": "Aucune configuration de recherche trouvée"
 }
-- 
GitLab