From be08dd3118731e06245ce2dfd494843ea33bcb87 Mon Sep 17 00:00:00 2001 From: Aday Bujeda Date: Thu, 19 Dec 2024 15:25:57 +0000 Subject: [PATCH] Fixed missing reviewer names in emails when creating a new reviewer in the add reviewer flow --- .../email/PPRFirstNameEmailService.inc.php | 15 +++++++++++++++ .../util/PPRFirstNamesManagementService.inc.php | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/pprOjsPlugin/services/email/PPRFirstNameEmailService.inc.php b/pprOjsPlugin/services/email/PPRFirstNameEmailService.inc.php index e492e2c..8376780 100644 --- a/pprOjsPlugin/services/email/PPRFirstNameEmailService.inc.php +++ b/pprOjsPlugin/services/email/PPRFirstNameEmailService.inc.php @@ -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')); } @@ -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(); diff --git a/pprOjsPlugin/util/PPRFirstNamesManagementService.inc.php b/pprOjsPlugin/util/PPRFirstNamesManagementService.inc.php index a934be1..d242ef5 100644 --- a/pprOjsPlugin/util/PPRFirstNamesManagementService.inc.php +++ b/pprOjsPlugin/util/PPRFirstNamesManagementService.inc.php @@ -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);