Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions api/src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,12 @@ function _remove_group_permission()

function _get_users()
{
// remove this after successfully completing LIMS-742 ticket
if($this->has_arg('pid')){
error_log("pid used (for ticket: https://jira.diamond.ac.uk/browse/LIMS-742)");
}

$rows = $this->userData->getUsers(
false,
$this->staff,
$this->argOrEmptyString('s'),
$this->argOrEmptyString('page'),
$this->argOrEmptyString('sort_by'),
$this->argOrEmptyString('pid'),
$this->proposalid,
$this->argOrEmptyString('PERSONID'),
$this->user->hasPermission('manage_users'),
Expand Down Expand Up @@ -206,7 +200,6 @@ function _get_users()
$this->argOrEmptyString('s'),
$this->argOrEmptyString('page'),
$this->argOrEmptyString('sort_by'),
$this->argOrEmptyString('pid'),
$this->proposalid,
$this->argOrEmptyString('PERSONID'),
$this->user->hasPermission('manage_users'),
Expand Down
5 changes: 2 additions & 3 deletions api/src/Model/Services/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function removeGroupPermission($userGroupId, $permisionId)
}


function getUsers($getCount, $isStaffMember, $stringMatch, $page, $sortBy = null, $pid=null, $proposalid = null, $personId = null, $isManager = false, $currentUserId = null, $gid = null, $pjid = null, $visitName = null, $perPage = 15, $isAscending = true, $isAll = false, $onlyLogins = false)
function getUsers($getCount, $isStaffMember, $stringMatch, $page, $sortBy = null, $proposalid = null, $personId = null, $isManager = false, $currentUserId = null, $gid = null, $pjid = null, $visitName = null, $perPage = 15, $isAscending = true, $isAll = false, $onlyLogins = false)
{
$args = array();

Expand Down Expand Up @@ -99,8 +99,7 @@ function getUsers($getCount, $isStaffMember, $stringMatch, $page, $sortBy = null
// This blocks means that non-staff can only see users on their proposal, except when they looking at a visit
// (i.e. the proposal that was checking is added to the where clause)
if ((($personId && !$isManager) // if you're not a manager: you're looking for a person
|| (!$isStaffMember && !$visitName)) // if you are not a staff member and not looking at a specific visit
|| $pid) // if you are looking for user based on a proposal, but this
|| (!$isStaffMember && !$visitName))) // if you are not a staff member and not looking at a specific visit
{
$where .= ' AND (prhp.proposalid=:' . (sizeof($args) + 1) . ' OR lc.proposalid=:' . (sizeof($args) + 2) . ' OR p.personid=:' . (sizeof($args) + 3) . ')';
array_push($args, $proposalid, $proposalid, $currentUserId);
Expand Down
4 changes: 2 additions & 2 deletions api/tests/Controllers/UserControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function testRemoveGroupPermissionWithNoGidSpecifiedReturnsError(): void
public function testGetUsersWithInvalidPersonIdReturnsNoData(): void
{
$this->userController->args['PERSONID'] = 88;
$this->dataLayerStub->expects($this->exactly(1))->method('getUsers')->with(false, false, '', '', '', '', '', 88, false, 231312, '', '', '', 15, true)->willReturn(array());
$this->dataLayerStub->expects($this->exactly(1))->method('getUsers')->with(false, false, '', '', '', '', 88, false, 231312, '', '', '', 15, true)->willReturn(array());
$this->slimStub->shouldReceive('halt')->times(1)->with(400, '{"status":400,"message":"No such user"}')->andThrow(new \Exception);
$this->expectException(\Exception::class);

Expand All @@ -255,7 +255,7 @@ public function testGetUsersWithPersonIdReturnsNoTotalData(): void
{
$response = $this->setUpCommonResponse();
$this->userController->args['PERSONID'] = 88;
$this->dataLayerStub->expects($this->exactly(1))->method('getUsers')->with(false, false, '', '', '', '', '', 88, false, 231312, '', '', '', 15, true)->willReturn(array(9));
$this->dataLayerStub->expects($this->exactly(1))->method('getUsers')->with(false, false, '', '', '', '', 88, false, 231312, '', '', '', 15, true)->willReturn(array(9));

$this->userController->_get_users();
$this->assertEquals(9, $response->getBody());
Expand Down
Loading
Loading