Skip to content

Commit

Permalink
fix missing varibale value in ORCID email template
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Sep 12, 2024
1 parent 92bc66a commit a965aaf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
4 changes: 2 additions & 2 deletions classes/mail/mailables/OrcidCollectAuthorId.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions classes/mail/mailables/OrcidRequestAuthorAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions classes/mail/traits/OrcidVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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(),
]);
}
}
2 changes: 1 addition & 1 deletion classes/orcid/actions/AuthorizeUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function execute(): void
echo '
<html><body><script type="text/javascript">' .
$this->renderFrontendErrorNotification($errorMessages) .
'opener.$("#profileTabs").tabs("load", 3);
'opener.$("#profileTabs").tabs("load", 0);
window.close();
</script></body></html>
';
Expand Down
4 changes: 2 additions & 2 deletions templates/form/orcidProfile.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="orcid_button_container">{$orcidIcon} {translate key='orcid.connect'}</div>
{/if}
</button>
<a href="{url router="page" page="orcid" op="about"}"> {translate key='orcid.about.title'}</a>
<a href="{url router="page" page="orcid" op="about"}">{translate key='orcid.about.title'}</a>
{/capture}


Expand All @@ -44,7 +44,7 @@
console.log(status + ", error: " + error);
{rdelim}
{rdelim});
var oauthWindow = window.open("{$orcidOAuthUrl}", "_blank", "toolbar=no, scrollbars=yes, width=500, height=700, top=500, left=500");
var oauthWindow = window.open("{$orcidOAuthUrl}", "_blank", "toolbar=no, scrollbars=yes, width=540, height=700, top=500, left=500");
oauthWindow.opener = self;
return false;
{rdelim}
Expand Down
16 changes: 11 additions & 5 deletions templates/frontend/pages/orcidVerify.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
{elseif $submissionNotPublished}
{translate key="orcid.verify.sendSubmissionToOrcid.notpublished"}
{/if}
<span class='orcid-redirect'>
<div class='orcid-redirect'>
{translate key="orcid.verify.success.redirect" contextName=$contextName}
</span>
</div>
{else}
<div class="orcid-failure">
{if $orcidAPIError}
Expand All @@ -65,8 +65,14 @@

{if $verifySuccess}
<script type="text/javascript">
setTimeout(function() {
window.location.href = "{$currentUrl}";
}, 5000); // 5 seconds
setTimeout(function() {
window.location.href = "{$currentUrl}";
}, 10000); // 10 seconds
</script>
<style>
.orcid-redirect{
font-weight: bold;
margin-top: 0.50rem;
}
</style>
{/if}
3 changes: 1 addition & 2 deletions templates/user/identityForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@

{if $orcidEnabled}

<div class="orcid_container section">
<div class="orcid_container">
{* 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"}

{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"}*}
<button id="deleteOrcidButton" type="button" class="pkp_button pkp_button_offset" style="margin-left: 1rem">{translate key='common.delete'}</button>
{/if}
{/fbvFormSection}
Expand Down

0 comments on commit a965aaf

Please sign in to comment.