Commit 13b6c8f4 authored by Tino Goratsch's avatar Tino Goratsch

- added a separate layout for the newsletter subscription

- minor improvements for the default email layouts
parent 6056afb4
......@@ -29,8 +29,8 @@ class AccountStatus
protected $accountHistoryRepository;
/**
* @param \ACP3\Core\Date $date
* @param \ACP3\Modules\ACP3\Newsletter\Model\Repository\AccountRepository $accountRepository
* @param \ACP3\Core\Date $date
* @param \ACP3\Modules\ACP3\Newsletter\Model\Repository\AccountRepository $accountRepository
* @param \ACP3\Modules\ACP3\Newsletter\Model\Repository\AccountHistoryRepository $accountHistoryRepository
*/
public function __construct(
......@@ -44,26 +44,24 @@ class AccountStatus
}
/**
* @param int $status
* @param int|array $id
* @param int $status
* @param int|array $entryId
*
* @return bool|int
*/
public function changeAccountStatus($status, $id)
public function changeAccountStatus($status, $entryId)
{
$bool = $this->accountRepository->update(
['status' => $status], $id
);
$result = $this->accountRepository->update(['status' => $status], $entryId);
if (is_array($id)) {
$accountId = $this->retrieveAccountId($id);
if (is_array($entryId)) {
$accountId = $this->retrieveAccountId($entryId);
$this->addAccountHistory($status, $accountId);
} else {
$this->addAccountHistory($status, $id);
$this->addAccountHistory($status, $entryId);
}
return $bool;
return $result;
}
/**
......@@ -83,18 +81,18 @@ class AccountStatus
}
/**
* @param array $id
* @param array $entry
*
* @return int
*/
protected function retrieveAccountId(array $id)
protected function retrieveAccountId(array $entry)
{
switch (key($id)) {
switch (key($entry)) {
case 'mail':
$account = $this->accountRepository->getOneByEmail($id['mail']);
$account = $this->accountRepository->getOneByEmail($entry['mail']);
break;
case 'hash':
$account = $this->accountRepository->getOneByHash($id['hash']);
$account = $this->accountRepository->getOneByHash($entry['hash']);
}
return (!empty($account)) ? $account['id'] : 0;
......
......@@ -144,34 +144,40 @@ class Subscribe
$systemSettings = $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME);
$settings = $this->config->getSettings(Schema::MODULE_NAME);
$subject = $this->translator->t('newsletter', 'subscribe_mail_subject', ['%title%' => $systemSettings['site_title']]);
$body = $this->translator->t('newsletter', 'subscribe_mail_body',
['{host}' => $this->request->getHost()]) . "\n\n";
$from = [
'email' => $settings['mail'],
'name' => $systemSettings['site_title']
];
$this->mailer
->reset()
->setFrom($from)
->setSubject($subject)
->setMailSignature($settings['mailsig']);
$body = $this->translator->t(
'newsletter',
'subscribe_mail_body',
['{host}' => $this->request->getHost()]
);
$body .= "\n\n";
$data = (new Core\Mailer\MailerMessage())
->setFrom([
'email' => $settings['mail'],
'name' => $systemSettings['site_title']
])
->setSubject($this->translator->t(
'newsletter',
'subscribe_mail_subject',
['%title%' => $systemSettings['site_title']]
))
->setMailSignature($settings['mailsig'])
->setRecipients($emailAddress);
if ($settings['html'] == 1) {
$this->mailer->setTemplate('newsletter/layout.email.tpl');
$data->setTemplate('newsletter/layout.email.subscribe.tpl');
$body .= '<a href="' . $url . '">' . $url . '<a>';
$this->mailer->setHtmlBody($this->stringFormatter->nl2p($body));
$data->setHtmlBody($this->stringFormatter->nl2p($body));
} else {
$body .= $url;
$this->mailer->setBody($body);
$data->setBody($body);
}
$this->mailer->setRecipients($emailAddress);
return $this->mailer->send();
return $this->mailer
->reset()
->setData($data)
->send();
}
/**
......
{extends file="asset:Newsletter/layout.email.tpl"}
......@@ -46,7 +46,7 @@
margin: 0 auto;
}
.logo {
height: 89px;
padding: 15px 0;
}
.text-left {
text-align: left;
......@@ -74,9 +74,9 @@
<center>
<table border="0" cellpadding="0" cellspacing="0" class="email-content-wrapper">
<tr>
<td class="text-center">
<td class="text-center logo">
{block EMAIL_HEADER}
<img src="{image file="logo.png" absolute=true}" alt="{site_title}" class="logo">
<img src="{image file="logo.png" absolute=true}" alt="{site_title}">
{/block}
</td>
</tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment