Skip to content

Commit c576f8d

Browse files
authored
Updates to allow for PO usage (#74)
* Updates to allow for PO usage This functionality was originally added for OpenXDMoD and as such did not take into account that PO would also be utilizing this endpoint. Logic has been added to the options building that defaults to not restricting the resources returned, but if the user does not have then they are restricted to seeing only the resources they have access to. * Updates per code review comments by @jpwhite4
1 parent d65901c commit c576f8d

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

classes/Rest/Controllers/AppKernelControllerProvider.php

+10-18
Original file line numberDiff line numberDiff line change
@@ -1585,9 +1585,6 @@ public function getAppKernelSuccessRate(Request $req, Application $app)
15851585
* Retrieves the raw numeric values for the AppKernel Performance Map. This endpoint provides
15861586
* the data for `CenterReportCardPortlet.js`
15871587
*
1588-
* **NOTE:** This function will throw an UnauthorizedException if the user making the request
1589-
* does not have the Center Director or Center Staff acl.
1590-
*
15911588
* @param Request $request
15921589
* @param Application $app
15931590
* @return JsonResponse
@@ -1598,14 +1595,6 @@ public function getRawPerformanceMap(Request $request, Application $app)
15981595
{
15991596
$user = $this->authorize($request);
16001597

1601-
// We need to ensure that only Center Director / Center Staff users are authorized to
1602-
// utilize this endpoint. Note, we do not utilize the `requirements` parameter of the above
1603-
// `authorize` call because it utilizes `XDUser::hasAcls` which only checks if the user has
1604-
// *all* of the supplied acls, not any of the supplied acls.
1605-
if ( ! ( $user->hasAcl(ROLE_ID_CENTER_DIRECTOR) || $user->hasAcl(ROLE_ID_CENTER_STAFF) ) ) {
1606-
throw new UnauthorizedHttpException('xdmod', "Unable to complete action. User is not authorized.");
1607-
}
1608-
16091598
$startDate = $this->getStringParam($request, 'start_date', true);
16101599
if ($startDate !== null) {
16111600
$startDate = new \DateTime($startDate);
@@ -1628,13 +1617,16 @@ public function getRawPerformanceMap(Request $request, Application $app)
16281617

16291618
$data = array();
16301619
try {
1631-
$perfMap = new \AppKernel\PerformanceMap(array(
1632-
'start_date' => $startDate,
1633-
'end_date' => $endDate,
1634-
'resource' => array('data' => $user->getResources()),
1635-
'appKer' => $appKernels,
1636-
'problemSize' => $problemSizes
1637-
));
1620+
$options = array(
1621+
'start_date' => $startDate,
1622+
'end_date' => $endDate,
1623+
'appKer' => $appKernels,
1624+
'problemSize' => $problemSizes
1625+
);
1626+
if (!$user->hasAcl(ROLE_ID_PROGRAM_OFFICER)) {
1627+
$options['resource'] = array('data' => $user->getResources());
1628+
}
1629+
$perfMap = new \AppKernel\PerformanceMap($options);
16381630

16391631
// The columns that we're going to be retrieving from the PerformanceMap and ultimately
16401632
// returning to the requester.

0 commit comments

Comments
 (0)