Skip to content

Commit

Permalink
[API] Candidates are now filtered by allowed project ids
Browse files Browse the repository at this point in the history
  • Loading branch information
spell00 committed Sep 1, 2020
1 parent 63a0158 commit 8a6893c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
23 changes: 13 additions & 10 deletions modules/api/php/models/candidatesrow.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CandidatesRow implements \LORIS\Data\DataInstance
{
private $_candid;
private $_projectname;
private $_projectid;
private $_pscid;
private $_sitename;
private $_edc;
Expand All @@ -40,6 +41,7 @@ class CandidatesRow implements \LORIS\Data\DataInstance
{
$this->_candid = $row['CandID'] ?? null;
$this->_projectname = $row['ProjectName'] ?? null;
$this->_projectid = $row['ProjectID'] ?? null;
$this->_pscid = $row['PSCID'] ?? null;
$this->_sitename = $row['SiteName'] ?? null;
$this->_edc = $row['EDC'] ?? null;
Expand All @@ -56,13 +58,14 @@ class CandidatesRow implements \LORIS\Data\DataInstance
public function jsonSerialize() : array
{
$obj = [
'CandID' => $this->_candid,
'Project' => $this->_projectname,
'PSCID' => $this->_pscid,
'Site' => $this->_sitename,
'EDC' => $this->_edc,
'DoB' => $this->_dob,
'Sex' => $this->_sex,
'CandID' => $this->_candid,
'Project' => $this->_projectname,
'ProjectID' => $this->_projectid,
'PSCID' => $this->_pscid,
'Site' => $this->_sitename,
'EDC' => $this->_edc,
'DoB' => $this->_dob,
'Sex' => $this->_sex,
];

return $obj;
Expand All @@ -86,13 +89,13 @@ class CandidatesRow implements \LORIS\Data\DataInstance
* Returns the ProjectID for this row, for filters such as
* \LORIS\Data\Filters\UserProjectMatch to match against.
*
* @return string ProjectID
* @return integer ProjectID
*/
public function getProjectID(): int
{
if ($this->_projectname === null) {
if ($this->_projectid === null) {
throw new \Exception('ProjectID is null');
}
return intval($this->_projectname);
return intval($this->_projectid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CandidatesProvisioner extends DBRowProvisioner
SELECT
c.CandID as CandID,
p.Name as ProjectName,
c.RegistrationProjectID as ProjectID,
c.PSCID as PSCID,
c.RegistrationCenterID as CenterID,
s.Name as SiteName,
Expand Down

0 comments on commit 8a6893c

Please sign in to comment.