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 4, 2024
1 parent 536f2c7 commit be5444a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 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(),
]);
}
}
4 changes: 0 additions & 4 deletions jobs/orcid/SendAuthorMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,7 +27,6 @@

class SendAuthorMail extends BaseJob
{

public function __construct(
private Author $author,
private Context $context,
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
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 be5444a

Please sign in to comment.