From be5444a09c54bb6c55e3d8840478397e0ec6d83f Mon Sep 17 00:00:00 2001 From: Taslan Graham Date: Wed, 4 Sep 2024 12:23:01 -0500 Subject: [PATCH] fix missing varibale value in ORCID email template --- classes/mail/mailables/OrcidCollectAuthorId.php | 4 ++-- .../mail/mailables/OrcidRequestAuthorAuthorization.php | 5 ++--- classes/mail/traits/OrcidVariables.php | 9 +++++++-- jobs/orcid/SendAuthorMail.php | 4 ---- templates/form/orcidProfile.tpl | 2 +- templates/user/identityForm.tpl | 3 +-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/classes/mail/mailables/OrcidCollectAuthorId.php b/classes/mail/mailables/OrcidCollectAuthorId.php index 2f1bbb8fd2a..dc9dd13f10f 100644 --- a/classes/mail/mailables/OrcidCollectAuthorId.php +++ b/classes/mail/mailables/OrcidCollectAuthorId.php @@ -14,11 +14,11 @@ namespace PKP\mail\mailables; -use PKP\mail\traits\OrcidVariables; use APP\submission\Submission; use PKP\context\Context; use PKP\mail\Mailable; use PKP\mail\traits\Configurable; +use PKP\mail\traits\OrcidVariables; use PKP\mail\traits\Recipient; use PKP\security\Role; @@ -36,7 +36,7 @@ class OrcidCollectAuthorId extends Mailable public function __construct(Context $context, Submission $submission, string $oauthUrl) { parent::__construct([$context, $submission]); - $this->setupOrcidVariables($oauthUrl); + $this->setupOrcidVariables($oauthUrl, $context); } /** diff --git a/classes/mail/mailables/OrcidRequestAuthorAuthorization.php b/classes/mail/mailables/OrcidRequestAuthorAuthorization.php index 8c6a24b4bcd..4eff4e1b850 100644 --- a/classes/mail/mailables/OrcidRequestAuthorAuthorization.php +++ b/classes/mail/mailables/OrcidRequestAuthorAuthorization.php @@ -12,14 +12,13 @@ * @brief An automatic email sent to the authors to add ORCIDs to a submission and request permission to push metadata to ORCID. */ - namespace PKP\mail\mailables; -use PKP\mail\traits\OrcidVariables; use APP\submission\Submission; use PKP\context\Context; use PKP\mail\Mailable; use PKP\mail\traits\Configurable; +use PKP\mail\traits\OrcidVariables; use PKP\mail\traits\Recipient; use PKP\security\Role; @@ -37,7 +36,7 @@ class OrcidRequestAuthorAuthorization extends Mailable public function __construct(Context $context, Submission $submission, string $oauthUrl) { parent::__construct([$context, $submission]); - $this->setupOrcidVariables($oauthUrl); + $this->setupOrcidVariables($oauthUrl, $context); } /** diff --git a/classes/mail/traits/OrcidVariables.php b/classes/mail/traits/OrcidVariables.php index 7a454520810..3188ef2ec04 100644 --- a/classes/mail/traits/OrcidVariables.php +++ b/classes/mail/traits/OrcidVariables.php @@ -17,13 +17,15 @@ namespace PKP\mail\traits; use APP\core\Application; +use APP\facades\Repo; +use PKP\context\Context; use PKP\mail\Mailable; trait OrcidVariables { protected static string $authorOrcidUrl = 'authorOrcidUrl'; protected static string $orcidAboutUrl = 'orcidAboutUrl'; - + protected static string $principalContactSignature = 'principalContactSignature'; abstract public function addData(array $data): Mailable; /** @@ -40,13 +42,16 @@ public static function getOrcidDataDescriptions(): array /** * Set values for additional email template variables */ - protected function setupOrcidVariables(string $oauthUrl): void + protected function setupOrcidVariables(string $oauthUrl, Context $context): void { $request = Application::get()->getRequest(); $dispatcher = Application::get()->getDispatcher(); + $principalContact = Repo::user()->getByEmail($context->getData('contactEmail')); + $this->addData([ self::$authorOrcidUrl => $oauthUrl, self::$orcidAboutUrl => $dispatcher->url($request, Application::ROUTE_PAGE, null, 'orcid', 'about', urlLocaleForPage: ''), + self::$principalContactSignature => $principalContact->getLocalizedSignature(), ]); } } diff --git a/jobs/orcid/SendAuthorMail.php b/jobs/orcid/SendAuthorMail.php index a02eb0590cc..505a35fffb3 100644 --- a/jobs/orcid/SendAuthorMail.php +++ b/jobs/orcid/SendAuthorMail.php @@ -17,11 +17,8 @@ namespace PKP\jobs\orcid; use APP\author\Author; -use APP\core\Application; use APP\facades\Repo; -use GuzzleHttp\Exception\ClientException; use Illuminate\Support\Facades\Mail; -use PKP\config\Config; use PKP\context\Context; use PKP\jobs\BaseJob; use PKP\mail\mailables\OrcidCollectAuthorId; @@ -30,7 +27,6 @@ class SendAuthorMail extends BaseJob { - public function __construct( private Author $author, private Context $context, diff --git a/templates/form/orcidProfile.tpl b/templates/form/orcidProfile.tpl index 3d700435ebd..5e152c2a356 100644 --- a/templates/form/orcidProfile.tpl +++ b/templates/form/orcidProfile.tpl @@ -18,7 +18,7 @@
{$orcidIcon} {translate key='orcid.connect'}
{/if} - {translate key='orcid.about.title'} + {translate key='orcid.about.title'} {/capture} diff --git a/templates/user/identityForm.tpl b/templates/user/identityForm.tpl index 5e838668f9e..66806679b66 100644 --- a/templates/user/identityForm.tpl +++ b/templates/user/identityForm.tpl @@ -52,7 +52,7 @@ {if $orcidEnabled} -
+
{* FIXME: The form element is still required for "connect ORCID" functionality to work. *} {fbvFormSection } {fbvElement type="text" label="user.orcid" name="orcid" id="orcid" value=$orcid maxlength="46"} @@ -60,7 +60,6 @@ {include file="form/orcidProfile.tpl"} {if $orcid && $orcidAuthenticated} {include file="linkAction/buttonConfirmationLinkAction.tpl" titleIcon="modal_delete" buttonSelector="#deleteOrcidButton" dialogText="orcid.field.deleteOrcidModal.message"} -{* {fbvElement type="button" label="common.delete" class="pkp_button pkp_button_offset"}*} {/if} {/fbvFormSection}