Skip to content

Commit

Permalink
[examiner] Adds permission check when adding examiner to site.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisadmin committed Apr 2, 2024
1 parent b7ff2c6 commit e0fc342
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
15 changes: 15 additions & 0 deletions modules/examiner/php/addexaminer.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ class AddExaminer extends \NDB_Page
$fullName = $values['addName'] ?? '';
$siteID = $values['addSite'] ?? '';

// check for site permissions
$user = \User::singleton();
if (!$user->hasAnyPermission(
[
'superuser',
'examiner_multisite',
]
)
&& !in_array($siteID, $user->getCenterIDs())
) {
return new \LORIS\Http\Response\JSON\Conflict(
'Permission denied: You cannot assign examiner to this Site.'
);
};

if ($this->examinerExists($fullName, $siteID)) {
return new \LORIS\Http\Response\JSON\Conflict(
'This examiner already exists.'
Expand Down
17 changes: 15 additions & 2 deletions modules/examiner/php/examiner.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,23 @@ class Examiner extends \DataFrameworkMenu

$useCertification = ($this->useCertification == 1) ? true : false;

$user = \User::singleton();
if ($user->hasAnyPermission(
[
'superuser',
'examiner_multisite',
]
)
) {
$sites = \Utility::getSiteList(false);
} else {
$sites = $user->getCenterIDs();
}
$sites = $user->getStudySites();
return [
'sites' => \Utility::getSiteList(false),
'sites' => $sites,
'radiologists' => $yesNoOptions,
'useCertification' => $useCertification,
'useCertification' => $useCertification,
];

}
Expand Down

0 comments on commit e0fc342

Please sign in to comment.