From 51c0a6bf1dd3320ae64e4a762073a9d3744fce41 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Mon, 5 Oct 2020 14:32:48 +0200 Subject: [PATCH] FEAT #13271 TIME 0:35 Search fixes --- src/app/search/controllers/SearchController.php | 10 +++------- test/unitTests/app/group/GroupControllerTest.php | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/app/search/controllers/SearchController.php b/src/app/search/controllers/SearchController.php index a5a644e287d..4b43c7495ad 100644 --- a/src/app/search/controllers/SearchController.php +++ b/src/app/search/controllers/SearchController.php @@ -18,17 +18,13 @@ use Attachment\models\AttachmentModel; use Basket\models\BasketModel; use Basket\models\RedirectBasketModel; use Configuration\models\ConfigurationModel; -use Contact\controllers\ContactController; use Contact\models\ContactModel; use Convert\controllers\FullTextController; use CustomField\models\CustomFieldModel; use Docserver\models\DocserverModel; -use Doctype\models\DoctypeModel; -use Entity\models\EntityModel; use Entity\models\ListInstanceModel; use Folder\models\ResourceFolderModel; use Note\models\NoteModel; -use Priority\models\PriorityModel; use RegisteredMail\models\RegisteredMailModel; use Resource\controllers\ResourceListController; use Resource\models\ResModel; @@ -396,9 +392,9 @@ class SearchController } if (!empty($body['status']) && !empty($body['status']['values']) && is_array($body['status']['values'])) { if (in_array(null, $body['status']['values'])) { - $args['searchWhere'][] = '(status in (?) OR status is NULL)'; + $args['searchWhere'][] = '(status in (select id from status where identifier in (?)) OR status is NULL)'; } else { - $args['searchWhere'][] = 'status in (?)'; + $args['searchWhere'][] = 'status in (select id from status where identifier in (?))'; } $args['searchData'][] = $body['status']['values']; } @@ -665,7 +661,7 @@ class SearchController } } if (!empty($body['groupSign']) && !empty($body['groupSign']['values']) && is_array($body['groupSign']['values'])) { - $args['searchWhere'][] = 'res_id in (select DISTINCT res_id from listinstance where requested_signature = ? AND item_id in (select DISTINCT user_id from usergroup_content where group_id in (?)))'; + $args['searchWhere'][] = 'res_id in (select DISTINCT res_id from listinstance where signatory = ? AND item_id in (select DISTINCT user_id from usergroup_content where group_id in (?)))'; $args['searchData'][] = 'true'; $args['searchData'][] = $body['groupSign']['values']; } diff --git a/test/unitTests/app/group/GroupControllerTest.php b/test/unitTests/app/group/GroupControllerTest.php index 3776433432a..49c1ce3d7a8 100755 --- a/test/unitTests/app/group/GroupControllerTest.php +++ b/test/unitTests/app/group/GroupControllerTest.php @@ -269,14 +269,13 @@ class GroupControllerTest extends TestCase $this->assertIsInt($value->id); } - // Fail $GLOBALS['login'] = 'bbain'; $userInfo = \User\models\UserModel::getByLogin(['login' => $GLOBALS['login'], 'select' => ['id']]); $GLOBALS['id'] = $userInfo['id']; $response = $groupController->get($request, new \Slim\Http\Response()); $this->assertSame(200, $response->getStatusCode()); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string)$response->getBody()); $this->assertNotEmpty($responseBody->groups); -- GitLab