Skip to content

Commit

Permalink
Fixed missing reviewer names in emails when creating a new reviewer i…
Browse files Browse the repository at this point in the history
…n the add reviewer flow
  • Loading branch information
abujeda committed Dec 19, 2024
1 parent c52d5b5 commit be08dd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pprOjsPlugin/services/email/PPRFirstNameEmailService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function register() {
HookRegistry::register('TemplateManager::fetch', array($this, 'replaceFirstNameInTemplateText'));

HookRegistry::register('advancedsearchreviewerform::display', array($this, 'addFirstNameLabelsToAdvancedSearchReviewerForm'));
HookRegistry::register('createreviewerform::display', array($this, 'addFirstNameLabelsToCreateReviewerForm'));
HookRegistry::register('createreviewerform::execute', array($this, 'addCreatedReviewerId'));

HookRegistry::register('LoadComponentHandler', array($this, 'addPPRStageParticipantGridHandler'));
}
Expand Down Expand Up @@ -109,6 +111,19 @@ function addFirstNameLabelsToAdvancedSearchReviewerForm($hookName, $arguments) {
return false;
}

function addFirstNameLabelsToCreateReviewerForm($hookName, $arguments) {
$this->pprObjectFactory->firstNamesManagementService()->addFirstNameLabelsToTemplate('emailVariables');

return false;
}

function addCreatedReviewerId($hookName, $arguments) {
$form = $arguments[0];
$reviewerId = $form->getData('reviewerId');
$templateMgr = TemplateManager::getManager(Application::get()->getRequest());
$templateMgr->assign(['reviewerId' => $reviewerId]);
}

function addFirstNamesToThankReviewerForm($hookName, $arguments) {
$thankReviewerForm = $arguments[0];
$review = $thankReviewerForm->getReviewAssignment();
Expand Down
4 changes: 4 additions & 0 deletions pprOjsPlugin/util/PPRFirstNamesManagementService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ public function replaceFirstNames($originalText, $submission, $reviewerId = null

public function getReviewer($reviewerId) {
$request = Application::get()->getRequest();
$templateMgr = TemplateManager::getManager($request);
$reviewer = null;
if ($reviewerId) {
$reviewer = $this->pprSubmissionUtil->getUser($reviewerId);
} elseif ($reviewerId = $request->getUserVar('reviewerId')) {
// TRY reviewerId REQUEST PARAMETER
$reviewer = $this->pprSubmissionUtil->getUser($reviewerId);
} elseif ($reviewerId = $templateMgr->getTemplateVars('reviewerId')) {
// TRY reviewerId IN TEMPLATE MANAGER
$reviewer = $this->pprSubmissionUtil->getUser($reviewerId);
} elseif ($reviewId = $request->getUserVar('reviewAssignmentId')) {
// TRY reviewAssignment REQUEST PARAMETER
$reviewer = $this->pprSubmissionUtil->getReviewer($reviewId);
Expand Down

0 comments on commit be08dd3

Please sign in to comment.