first commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/mail/variables/ContextEmailVariable.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class ContextEmailVariable
|
||||
*
|
||||
* @ingroup mail_variables
|
||||
*
|
||||
* @brief Represents journal-specific email template variables
|
||||
*/
|
||||
|
||||
namespace APP\mail\variables;
|
||||
|
||||
use PKP\mail\variables\ContextEmailVariable as PKPContextEmailVariable;
|
||||
|
||||
class ContextEmailVariable extends PKPContextEmailVariable
|
||||
{
|
||||
public const CONTEXT_NAME = 'journalName';
|
||||
public const CONTEXT_URL = 'journalUrl';
|
||||
public const CONTEXT_SIGNATURE = 'journalSignature';
|
||||
public const CONTEXT_ACRONYM = 'journalAcronym';
|
||||
|
||||
/**
|
||||
* @copydoc Variable::descriptions()
|
||||
*/
|
||||
public static function descriptions(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::descriptions(),
|
||||
[
|
||||
static::CONTEXT_ACRONYM => __('emailTemplate.variable.context.contextAcronym'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Variable::values()
|
||||
*/
|
||||
public function values(string $locale): array
|
||||
{
|
||||
$values = array_merge(
|
||||
parent::values($locale),
|
||||
[
|
||||
static::CONTEXT_ACRONYM => htmlspecialchars($this->context->getLocalizedData('acronym')),
|
||||
],
|
||||
);
|
||||
|
||||
// Pass the values into the context signature so variables
|
||||
// used in the signature can be rendered.
|
||||
$values[static::CONTEXT_SIGNATURE] = $this->getContextSignature($values);
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/mail/variables/IssueEmailVariable.php
|
||||
*
|
||||
* Copyright (c) 2014-2023 Simon Fraser University
|
||||
* Copyright (c) 2000-2023 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class IssueEmailVariable
|
||||
*
|
||||
* @ingroup mail_variables
|
||||
*
|
||||
* @brief Email template variables for an issue.
|
||||
*/
|
||||
|
||||
namespace APP\mail\variables;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\issue\Issue;
|
||||
use PKP\mail\Mailable;
|
||||
use PKP\mail\variables\Variable;
|
||||
|
||||
class IssueEmailVariable extends Variable
|
||||
{
|
||||
public const ISSUE_ID = 'issueId';
|
||||
public const ISSUE_IDENTIFICATION = 'issueIdentification';
|
||||
public const ISSUE_URL = 'issueUrl';
|
||||
|
||||
protected Issue $issue;
|
||||
|
||||
public function __construct(Issue $issue, Mailable $mailable)
|
||||
{
|
||||
parent::__construct($mailable);
|
||||
|
||||
$this->issue = $issue;
|
||||
}
|
||||
|
||||
public static function descriptions(): array
|
||||
{
|
||||
return
|
||||
[
|
||||
static::ISSUE_ID => __('emailTemplate.variable.issueId'),
|
||||
static::ISSUE_IDENTIFICATION => __('emailTemplate.variable.issue.issueIdentification'),
|
||||
static::ISSUE_URL => __('emailTemplate.variable.issue.issuePublishedUrl'),
|
||||
];
|
||||
}
|
||||
|
||||
public function values(string $locale): array
|
||||
{
|
||||
return
|
||||
[
|
||||
static::ISSUE_ID => $this->issue->getId(),
|
||||
static::ISSUE_IDENTIFICATION => htmlspecialchars($this->issue->getIssueIdentification()),
|
||||
static::ISSUE_URL => $this->getIssueUrl(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getIssueUrl(): string
|
||||
{
|
||||
return Application::get()->getDispatcher()->url(
|
||||
Application::get()->getRequest(),
|
||||
Application::ROUTE_PAGE,
|
||||
$this->getContext()->getPath(),
|
||||
'issue',
|
||||
'view',
|
||||
$this->issue->getBestIssueId()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/mail/variables/SubmissionEmailVariable.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class SubmissionEmailVariable
|
||||
*
|
||||
* @ingroup mail_variables
|
||||
*
|
||||
* @brief Represents variables associated with a submission that can be assigned to a template
|
||||
*/
|
||||
|
||||
namespace APP\mail\variables;
|
||||
|
||||
use APP\core\Application;
|
||||
use PKP\context\Context;
|
||||
|
||||
class SubmissionEmailVariable extends \PKP\mail\variables\SubmissionEmailVariable
|
||||
{
|
||||
protected function getSubmissionPublishedUrl(Context $context): string
|
||||
{
|
||||
return Application::get()->getDispatcher()->url(
|
||||
Application::get()->getRequest(),
|
||||
Application::ROUTE_PAGE,
|
||||
$context->getPath(),
|
||||
'article',
|
||||
'view',
|
||||
$this->submission->getBestId()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/mail/variables/SubscriptionEmailVariable.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 SubscriptionEmailVariable
|
||||
*
|
||||
* @ingroup mail_variables
|
||||
*
|
||||
* @brief Represents variables associated with a subscription
|
||||
*/
|
||||
|
||||
namespace APP\mail\variables;
|
||||
|
||||
use APP\facades\Repo;
|
||||
use APP\journal\Journal;
|
||||
use APP\subscription\Subscription;
|
||||
use PKP\core\PKPString;
|
||||
use PKP\mail\Mailable;
|
||||
use PKP\mail\variables\Variable;
|
||||
use PKP\user\User;
|
||||
|
||||
class SubscriptionEmailVariable extends Variable
|
||||
{
|
||||
public const SUBSCRIBER_DETAILS = 'subscriberDetails';
|
||||
public const SUBSCRIPTION_SIGNATURE = 'subscriptionSignature';
|
||||
public const EXPIRY_DATE = 'expiryDate';
|
||||
public const MEMBERSHIP = 'membership';
|
||||
|
||||
protected User $subscriber;
|
||||
protected Subscription $subscription;
|
||||
|
||||
public function __construct(Subscription $subscription, Mailable $mailable)
|
||||
{
|
||||
parent::__construct($mailable);
|
||||
|
||||
$this->subscriber = Repo::user()->get($subscription->getUserId());
|
||||
$this->subscription = $subscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Variable::descriptions()
|
||||
*/
|
||||
public static function descriptions(): array
|
||||
{
|
||||
return
|
||||
[
|
||||
self::SUBSCRIBER_DETAILS => __('emailTemplate.variable.subscription.subscriberDetails'),
|
||||
self::SUBSCRIPTION_SIGNATURE => __('emailTemplate.variable.subscription.subscriptionSignature'),
|
||||
self::EXPIRY_DATE => __('emailTemplate.variable.subscription.expiryDate'),
|
||||
self::MEMBERSHIP => __('emailTemplate.variable.subscription.membership'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Variable::values()
|
||||
*/
|
||||
public function values(string $locale): array
|
||||
{
|
||||
$context = $this->getContext();
|
||||
return
|
||||
[
|
||||
self::SUBSCRIBER_DETAILS => PKPString::stripUnsafeHtml($this->subscriber->getSignature($locale) ?? ''),
|
||||
self::SUBSCRIPTION_SIGNATURE => $this->getSubscriptionSignature($context),
|
||||
self::EXPIRY_DATE => $this->subscription->getDateEnd(),
|
||||
self::MEMBERSHIP => htmlspecialchars($this->subscription->getMembership()),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscription signature consisting of contact details of the person responsible for subscriptions included in the
|
||||
* context's Subscription Policies form, Subscription Manager section
|
||||
*/
|
||||
protected function getSubscriptionSignature(Journal $context): string
|
||||
{
|
||||
$subscriptionName = htmlspecialchars($context->getData('subscriptionName'));
|
||||
$subscriptionEmail = htmlspecialchars($context->getData('subscriptionEmail'));
|
||||
$subscriptionPhone = htmlspecialchars($context->getData('subscriptionPhone'));
|
||||
$subscriptionMailingAddress = PKPString::stripUnsafeHtml($context->getData('subscriptionMailingAddress'));
|
||||
$subscriptionContactSignature = $subscriptionName;
|
||||
|
||||
if ($subscriptionMailingAddress != '') {
|
||||
$subscriptionContactSignature .= "\n" . $subscriptionMailingAddress;
|
||||
}
|
||||
if ($subscriptionPhone != '') {
|
||||
$subscriptionContactSignature .= "\n" . __('user.phone') . ': ' . $subscriptionPhone;
|
||||
}
|
||||
|
||||
return $subscriptionContactSignature . "\n" . __('user.email') . ': ' . $subscriptionEmail;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user