forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp#9453 Let reviewers view their recommendations for previous rounds
- Loading branch information
Showing
9 changed files
with
472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
|
||
/** | ||
* @defgroup controllers_review Review Handlers | ||
*/ | ||
|
||
/** | ||
* @file controllers/review/ReviewRoundModalHandler.inc.php | ||
* | ||
* Copyright (c) 2014-2021 Simon Fraser University | ||
* Copyright (c) 2003-2021 John Willinsky | ||
* Copyright (c) 2021 Université Laval | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class ReviewRoundModalHandler | ||
* @ingroup controllers_review | ||
* | ||
* @brief Reviewer review round info handler. | ||
*/ | ||
|
||
namespace PKP\controllers\review; | ||
|
||
use APP\facades\Repo; | ||
use APP\handler\Handler; | ||
use APP\template\TemplateManager; | ||
use Exception; | ||
use PKP\core\JSONMessage; | ||
use PKP\core\PKPRequest; | ||
use PKP\log\SubmissionEmailLogEntry; | ||
use PKP\security\authorization\RoleBasedHandlerOperationPolicy; | ||
use PKP\db\DAORegistry; | ||
use PKP\security\Role; | ||
|
||
class ReviewRoundModalHandler extends Handler | ||
{ | ||
/** | ||
* Constructor | ||
*/ | ||
function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->addRoleAssignment( | ||
[Role::ROLE_ID_REVIEWER], | ||
['viewRoundInfo', 'closeModal'] | ||
); | ||
} | ||
|
||
// | ||
// Implement template methods from PKPHandler. | ||
// | ||
|
||
/** | ||
* @copydoc PKPHandler::authorize() | ||
*/ | ||
function authorize($request, &$args, $roleAssignments): bool | ||
{ | ||
$this->addPolicy(new RoleBasedHandlerOperationPolicy( | ||
$request, | ||
[Role::ROLE_ID_REVIEWER], | ||
['viewRoundInfo', 'close'] | ||
)); | ||
|
||
return parent::authorize($request, $args, $roleAssignments); | ||
} | ||
|
||
// | ||
// Public operations | ||
// | ||
|
||
/** | ||
* Display the review round info modal. | ||
* | ||
* @param array $args | ||
* @param PKPRequest $request | ||
* | ||
* @return JSONMessage JSON object | ||
* @throws Exception | ||
*/ | ||
function viewRoundInfo($args, $request) | ||
{ | ||
$this->setupTemplate($request); | ||
|
||
$submission = Repo::submission()->get($args['submissionId']); | ||
$submissionId = $submission->getId(); | ||
$reviewerId = $request->getUser()->getId(); | ||
|
||
$reviewAssignments = Repo::reviewAssignment()->getCollector() | ||
->filterByReviewerIds([$reviewerId]) | ||
->getMany(); | ||
$declinedReviewAssignments = array(); | ||
foreach ($reviewAssignments as $submissionReviewAssignment) { | ||
if ($submissionReviewAssignment->getDeclined() and $submissionId == $submissionReviewAssignment->getSubmissionId()) { | ||
$declinedReviewAssignments[] = $submissionReviewAssignment; | ||
} | ||
} | ||
|
||
$reviewAssignment = Repo::reviewAssignment()->getCollector() | ||
->filterByReviewRoundIds([$args['reviewRoundId']]) | ||
->filterByReviewerIds([$reviewerId]) | ||
->filterByContextIds([$request->getContext()->getId()]) | ||
->getMany() | ||
->first(); | ||
$submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO'); | ||
$reviewComments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignment->getId()); | ||
|
||
$reviewRoundNumber = $args['reviewRoundNumber']; | ||
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO'); | ||
$emailLogs = $submissionEmailLogDao | ||
->getBySenderId($submissionId, SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_DECLINE, $reviewerId) | ||
->toArray(); | ||
$declineEmail = null; | ||
$i = 0; | ||
foreach ($declinedReviewAssignments as $declinedReviewAssignment) { | ||
if (isset($emailLogs[$i]) && $reviewRoundNumber == $declinedReviewAssignment->getRound()) { | ||
$declineEmail = $emailLogs[$i]; | ||
} | ||
$i++; | ||
} | ||
|
||
$displayFilesGrid = true; | ||
$lastReviewAssignment = Repo::reviewAssignment()->getCollector() | ||
->filterBySubmissionIds([$submissionId]) | ||
->filterByReviewerIds([$reviewerId]) | ||
->filterByLastReviewRound(true) | ||
->getMany() | ||
->first(); | ||
if($lastReviewAssignment->getDeclined() == 1) { | ||
$displayFilesGrid = false; | ||
} | ||
|
||
$templateMgr = TemplateManager::getManager($request); | ||
$templateMgr->assign([ | ||
'submission' => $submission, | ||
'reviewAssignment' => $reviewAssignment, | ||
'reviewRoundNumber' => $reviewRoundNumber, | ||
'reviewRoundId' => $args['reviewRoundId'], | ||
'reviewComments' => $reviewComments, | ||
'declineEmail' => $declineEmail, | ||
'displayFilesGrid' => $displayFilesGrid | ||
]); | ||
|
||
return $templateMgr->fetchJson('controllers/modals/reviewRound/reviewRound.tpl'); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
controllers/review/linkAction/ReviewRoundModalLinkAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/** | ||
* @file controllers/review/linkAction/ReviewRoundModalLinkAction.php | ||
* | ||
* Copyright (c) 2014-2021 Simon Fraser University | ||
* Copyright (c) 2003-2021 John Willinsky | ||
* Copyright (c) 2021 Université Laval | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class ReviewRoundModalLinkAction | ||
* | ||
* @ingroup controllers_review_linkAction | ||
* | ||
* @brief An action to show a modal with the information about a review round. | ||
*/ | ||
|
||
namespace PKP\controllers\review\linkAction; | ||
|
||
use APP\core\Request; | ||
use Exception; | ||
use PKP\core\PKPApplication; | ||
use PKP\linkAction\LinkAction; | ||
use PKP\linkAction\request\AjaxModal; | ||
use APP\facades\Repo; | ||
|
||
class ReviewRoundModalLinkAction extends LinkAction | ||
{ | ||
/** @var int The round number */ | ||
public int $_round; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param Request $request | ||
* @param int $submissionId The ID of the submission to present link for | ||
* @param int $reviewRoundId The ID of the review round | ||
* @param int $reviewRoundNumber The round number to show information about | ||
* @throws Exception | ||
*/ | ||
public function __construct($request, $submissionId, $reviewRoundId, $reviewRoundNumber) | ||
{ | ||
$this->_round = $reviewRoundNumber; | ||
|
||
$submission = Repo::submission()->get($submissionId); | ||
$submissionTitle = $submission->getCurrentPublication()->getLocalizedTitle(); | ||
$router = $request->getRouter(); | ||
$actionArgs = [ | ||
'submissionId' => $submissionId, | ||
'reviewRoundId' => $reviewRoundId, | ||
'reviewRoundNumber' => $reviewRoundNumber | ||
]; | ||
|
||
$ajaxModal = new AjaxModal( | ||
$router->getDispatcher()->url( | ||
$request, | ||
PKPApplication::ROUTE_COMPONENT, | ||
null, | ||
'review.ReviewRoundModalHandler', | ||
'viewRoundInfo', | ||
null, | ||
$actionArgs | ||
), | ||
__( | ||
'reviewer.submission.reviewRound.info.modal.title', | ||
[ | ||
'reviewRoundNumber' => $reviewRoundNumber, | ||
'submissionTitle' => $submissionTitle | ||
] | ||
), | ||
'modal_information' | ||
); | ||
|
||
// Configure the link action. | ||
parent::__construct('viewRoundInfo', $ajaxModal); | ||
} | ||
|
||
/** | ||
* Get the review round number. | ||
* | ||
* @return int | ||
*/ | ||
function getRound(): int | ||
{ | ||
return $this->_round; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.