Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4 from SURFnet/51-support-searching-for-multiple-…
Browse files Browse the repository at this point in the history
…roles

51 Support searching for multiple roles
  • Loading branch information
Tjeerd authored Nov 30, 2016
2 parents afc64dd + a483e62 commit 3c656ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/AppBundle/Controller/GroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function deleteGroupAction($id)
* {"name"="sort", "dataType"="string", "required"=false, "description"="sort property, prefix with '-' to change the order"},
* {"name"="query", "dataType"="string", "required"=false, "description"="search filter"},
* {"name"="users", "dataType"="array", "required"=false, "description"="array with user ids"},
* {"name"="role", "dataType"="string", "required"=false, "description"="role filter"}
* {"name"="roles", "dataType"="array", "required"=false, "description"="role filter"}
* },
* output="ArrayCollection<AppBundle\Entity\User>",
* statusCodes = {
Expand All @@ -284,9 +284,9 @@ public function getGroupUsersAction(Request $request, $id)
$sort = $request->query->get('sort', 'reference');
$query = $request->query->get('query');
$users = (array)$request->query->get('users');
$role = $request->query->get('role');
$roles = $request->query->get('roles');

$result = $this->get('app.manager.membership')->findMemberships($id, $query, $role, $users, $sort, $offset, $limit);
$result = $this->get('app.manager.membership')->findMemberships($id, $query, $roles, $users, $sort, $offset, $limit);

return $this->view($result);
}
Expand Down
8 changes: 4 additions & 4 deletions src/AppBundle/Manager/MembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function findMembership($userId, $groupId)
/**
* @param int $groupId
* @param string $query
* @param string $role
* @param array $roles
* @param array $users
* @param string $sort
* @param int $offset
Expand All @@ -64,7 +64,7 @@ public function findMembership($userId, $groupId)
public function findMemberships(
$groupId,
$query = null,
$role = null,
array $roles = null,
array $users = [],
$sort = 'reference',
$offset = 0,
Expand Down Expand Up @@ -97,8 +97,8 @@ public function findMemberships(
$limit = count($users);
}

if (!empty($role)) {
$qb->andWhere('ug.role = :role')->setParameter('role', $role);
if (!empty($roles)) {
$qb->andWhere($qb->expr()->in('ug.role', $roles));
}

if ($sort === 'name') {
Expand Down

0 comments on commit 3c656ac

Please sign in to comment.