first commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file plugins/generic/orcidProfile/mailables/OrcidCollectAuthorId.php
|
||||
*
|
||||
* Copyright (c) 2014-2022 Simon Fraser University
|
||||
* Copyright (c) 2000-2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class OrcidCollectAuthorId
|
||||
*
|
||||
* @ingroup mailables
|
||||
*
|
||||
* @brief This email is sent to collect the ORCID id's from authors
|
||||
*/
|
||||
|
||||
namespace APP\plugins\generic\orcidProfile\mailables;
|
||||
|
||||
use APP\journal\Journal;
|
||||
use APP\plugins\generic\orcidProfile\mailables\traits\OrcidVariables;
|
||||
use APP\submission\Submission;
|
||||
use PKP\mail\Mailable;
|
||||
use PKP\mail\traits\Configurable;
|
||||
use PKP\mail\traits\Recipient;
|
||||
use PKP\security\Role;
|
||||
|
||||
class OrcidCollectAuthorId extends Mailable
|
||||
{
|
||||
use Configurable;
|
||||
use Recipient;
|
||||
use OrcidVariables;
|
||||
|
||||
protected static ?string $name = 'plugins.generic.orcidProfile.orcidCollectAuthorId.name';
|
||||
protected static ?string $description = 'emails.orcidCollectAuthorId.description';
|
||||
protected static ?string $emailTemplateKey = 'ORCID_COLLECT_AUTHOR_ID';
|
||||
protected static array $toRoleIds = [Role::ROLE_ID_AUTHOR];
|
||||
|
||||
public function __construct(Journal $context, Submission $submission, string $oauthUrl)
|
||||
{
|
||||
parent::__construct([$context, $submission]);
|
||||
$this->setupOrcidVariables($oauthUrl);
|
||||
}
|
||||
|
||||
public static function getDataDescriptions(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::getDataDescriptions(),
|
||||
static::getOrcidDataDescriptions()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file plugins/generic/orcidProfile/mailables/OrcidRequestAuthorAuthorization.php
|
||||
*
|
||||
* Copyright (c) 2014-2022 Simon Fraser University
|
||||
* Copyright (c) 2000-2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class OrcidRequestAuthorAuthorization
|
||||
*
|
||||
* @ingroup mailables
|
||||
*
|
||||
* @brief This email is sent to request ORCID record access from authors
|
||||
*/
|
||||
|
||||
namespace APP\plugins\generic\orcidProfile\mailables;
|
||||
|
||||
use APP\journal\Journal;
|
||||
use APP\plugins\generic\orcidProfile\mailables\traits\OrcidVariables;
|
||||
use APP\server\Server;
|
||||
use APP\submission\Submission;
|
||||
use PKP\mail\Mailable;
|
||||
use PKP\mail\traits\Configurable;
|
||||
use PKP\mail\traits\Recipient;
|
||||
use PKP\security\Role;
|
||||
|
||||
class OrcidRequestAuthorAuthorization extends Mailable
|
||||
{
|
||||
use Configurable;
|
||||
use Recipient;
|
||||
use OrcidVariables;
|
||||
|
||||
protected static ?string $name = 'plugins.generic.orcidProfile.orcidRequestAuthorAuthorization.name';
|
||||
protected static ?string $description = 'emails.orcidRequestAuthorAuthorization.description';
|
||||
protected static ?string $emailTemplateKey = 'ORCID_REQUEST_AUTHOR_AUTHORIZATION';
|
||||
protected static array $toRoleIds = [Role::ROLE_ID_AUTHOR];
|
||||
|
||||
public function __construct(Journal|Server $context, Submission $submission, string $oauthUrl)
|
||||
{
|
||||
parent::__construct([$context, $submission]);
|
||||
$this->setupOrcidVariables($oauthUrl);
|
||||
}
|
||||
|
||||
public static function getDataDescriptions(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::getDataDescriptions(),
|
||||
static::getOrcidDataDescriptions()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file plugins/generic/orcidProfile/mailables/traits/OrcidVariables.php
|
||||
*
|
||||
* Copyright (c) 2014-2022 Simon Fraser University
|
||||
* Copyright (c) 2000-2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class OrcidVariables
|
||||
*
|
||||
* @ingroup mailables_traits
|
||||
*
|
||||
* @brief Mailable trait to set additional template variables for ORCID-related emails
|
||||
*/
|
||||
|
||||
namespace APP\plugins\generic\orcidProfile\mailables\traits;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\mail\Mailable;
|
||||
|
||||
trait OrcidVariables
|
||||
{
|
||||
protected static string $authorOrcidUrl = 'authorOrcidUrl';
|
||||
protected static string $orcidAboutUrl = 'orcidAboutUrl';
|
||||
|
||||
abstract public function addData(array $data): Mailable;
|
||||
|
||||
/**
|
||||
* Description of additional template variables
|
||||
*/
|
||||
public static function getOrcidDataDescriptions(): array
|
||||
{
|
||||
return [
|
||||
self::$authorOrcidUrl => __('emailTemplate.variable.authorOrcidUrl'),
|
||||
self::$orcidAboutUrl => __('emailTemplate.variable.orcidAboutUrl'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set values for additional email template variables
|
||||
*/
|
||||
protected function setupOrcidVariables(string $oauthUrl): void
|
||||
{
|
||||
$request = Application::get()->getRequest();
|
||||
$dispatcher = Application::get()->getDispatcher();
|
||||
$this->addData([
|
||||
self::$authorOrcidUrl => $oauthUrl,
|
||||
self::$orcidAboutUrl => $dispatcher->url($request, Application::ROUTE_PAGE, null, 'orcidapi', 'about'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user