Commit a785fe9a authored by Moreau Elise's avatar Moreau Elise
Browse files

check current user when searching process

parent 9ef9940c
......@@ -32,7 +32,7 @@ class SearchAction extends Action
$parsedRequestBody = (array)$this->request->getParsedBody();
$search = $this->checkvalue($parsedRequestBody['search']);
$users_query = $this->userRepository->createQueryBuilder('u');
$users_list = $users_query
->where('u.username LIKE :search')
......@@ -43,6 +43,13 @@ class SearchAction extends Action
->getResult();
$groups_query = $this->groupRepository->createQueryBuilder('g');
if (isset($_SESSION['userId'])){
$currentUser = $_SESSION['userId'];
}
else {
$currentUser=0;
}
$groups_list = $groups_query
->where('g.name LIKE :search')
->andWhere($groups_query->expr()->orX(
......@@ -51,7 +58,7 @@ class SearchAction extends Action
))
->setParameters(array(
':user_id' => $_SESSION['userId'],
':user_id' => $currentUser,
':search' => '%' . $search . '%'
))
->getQuery()
......@@ -59,8 +66,8 @@ class SearchAction extends Action
return $this->twig->render(
$this->response,
"/home/search.twig",
$this->response,
"/home/search.twig",
["users" => $users_list, "groups" => $groups_list, "session" => $_SESSION]
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment