Skip to content

Commit 40eb34e

Browse files
committed
IBX-9667: Updated emails template
1 parent 5d081c8 commit 40eb34e

File tree

6 files changed

+106
-56
lines changed

6 files changed

+106
-56
lines changed

src/bundle/Controller/PasswordResetController.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Ibexa\User\View\ResetPassword\FormView as UserResetPasswordFormView;
3232
use Ibexa\User\View\ResetPassword\InvalidLinkView;
3333
use Ibexa\User\View\ResetPassword\SuccessView as UserResetPasswordSuccessView;
34+
use Swift_Image;
3435
use Swift_Mailer;
3536
use Swift_Message;
3637
use Symfony\Component\HttpFoundation\Request;
@@ -82,6 +83,7 @@ public function __construct(
8283
*/
8384
public function userForgotPasswordAction(Request $request, ?string $reason = null)
8485
{
86+
8587
$form = $this->formFactory->forgotUserPassword();
8688
$form->handleRequest($request);
8789

@@ -249,12 +251,19 @@ private function sendResetPasswordMessage(User $user, string $hashKey): void
249251

250252
$subject = $template->renderBlock('subject', []);
251253
$from = $template->renderBlock('from', []) ?: $senderAddress;
252-
$body = $template->renderBlock('body', ['hash_key' => $hashKey]);
253254

254255
$message = (new Swift_Message())
255256
->setSubject($subject)
256-
->setTo($user->email)
257-
->setBody($body, 'text/html');
257+
->setTo($user->email);
258+
259+
$mailImagesDir = dirname(__DIR__, 6) . '/public/bundles/ibexaadminui/img/mail/';
260+
$embeddedHeader = $message->embed(Swift_Image::fromPath($mailImagesDir . 'header.png'));
261+
262+
$body = $template->renderBlock('body', [
263+
'hash_key' => $hashKey,
264+
'header_img_path' => $embeddedHeader,
265+
]);
266+
$message->setBody($body, 'text/html');
258267

259268
if (empty($from) === false) {
260269
$message->setFrom($from);

src/bundle/Resources/translations/ibexa_forgot_password.en.xliff

+25-17
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,6 @@
1616
<target state="new">This email is connected with several accounts. Enter your username instead.</target>
1717
<note>key: ezplatform.forgot_password.login</note>
1818
</trans-unit>
19-
<trans-unit id="1af697cb32b6eeeafbf4ca827e766829eac0e992" resname="ezplatform.forgot_password.message">
20-
<source><![CDATA[Hello,
21-
<br /><br />
22-
We have received a request to reset the password for your account. Click “reset password” below to choose a new password:
23-
<br /><br />
24-
<a href="%reset_password%">Reset password<a/>
25-
<br /><br />
26-
If you did not request a password reset, please ignore this email, and your password will remain the same.]]></source>
27-
<target state="new"><![CDATA[Hello,
28-
<br /><br />
29-
We have received a request to reset the password for your account. Click “reset password” below to choose a new password:
30-
<br /><br />
31-
<a href="%reset_password%">Reset password<a/>
32-
<br /><br />
33-
If you did not request a password reset, please ignore this email, and your password will remain the same.]]></target>
34-
<note>key: ezplatform.forgot_password.message</note>
35-
</trans-unit>
3619
<trans-unit id="9d77404b1f40b0458d3b82757b067e15c7dc46e3" resname="ezplatform.forgot_password.reset_your_password">
3720
<source>Reset your password</source>
3821
<target state="new">Reset your password</target>
@@ -54,6 +37,31 @@
5437
<p>If you reset your password multiple times, only the most recent password reset link will be valid.</p>]]></target>
5538
<note>key: ezplatform.forgot_password.success</note>
5639
</trans-unit>
40+
<trans-unit id="e7b58c781e23a49ce354cdb479f14d6f75ca6e4f" resname="forgot_user_password.mail.message">
41+
<source>We have received a request to reset the password for your account. Click "reset password" below to choose a new password:</source>
42+
<target state="new">We have received a request to reset the password for your account. Click "reset password" below to choose a new password:</target>
43+
<note>key: forgot_user_password.mail.message</note>
44+
</trans-unit>
45+
<trans-unit id="26ccb574b6cd1e49d40d32d9183db89065138be2" resname="forgot_user_password.mail.message_footer">
46+
<source>If you did not request a password reset, please ignore this email, and your password will remain the same.</source>
47+
<target state="new">If you did not request a password reset, please ignore this email, and your password will remain the same.</target>
48+
<note>key: forgot_user_password.mail.message_footer</note>
49+
</trans-unit>
50+
<trans-unit id="a5ba92910b3dc61efc12c4f42cc869975be98723" resname="forgot_user_password.mail.message_title">
51+
<source>Hello,</source>
52+
<target state="new">Hello,</target>
53+
<note>key: forgot_user_password.mail.message_title</note>
54+
</trans-unit>
55+
<trans-unit id="b7293d1f766a95b50cf3e076c5ef4cd623dc542c" resname="forgot_user_password.mail.reset_password">
56+
<source>Reset password</source>
57+
<target state="new">Reset password</target>
58+
<note>key: forgot_user_password.mail.reset_password</note>
59+
</trans-unit>
60+
<trans-unit id="5fd68a8b7cdaa23771e0e970466b4432642df1d3" resname="forgot_user_password.mail.reset_your_password">
61+
<source>Reset your password</source>
62+
<target state="new">Reset your password</target>
63+
<note>key: forgot_user_password.mail.reset_your_password</note>
64+
</trans-unit>
5765
</body>
5866
</file>
5967
</xliff>

src/bundle/Resources/translations/ibexa_user_invitation.en.xliff

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
77
</header>
88
<body>
9+
<trans-unit id="07c52e99431e40b768788c64536e4dc12ade0f03" resname="ibexa.user.invitation.mail.join">
10+
<source>Join</source>
11+
<target state="new">Join</target>
12+
<note>key: ibexa.user.invitation.mail.join</note>
13+
</trans-unit>
914
<trans-unit id="bc254dd11e21f88f3d7b2a1a9c8ab30bb6825702" resname="ibexa.user.invitation.mail.message">
1015
<source xml:space="preserve">Hello,
1116
Join us at: %invite_link%
@@ -15,6 +20,11 @@
1520
</target>
1621
<note>key: ibexa.user.invitation.mail.message</note>
1722
</trans-unit>
23+
<trans-unit id="56996e20d695f581a1344e83a8c542c7df1a04ec" resname="ibexa.user.invitation.mail.message_title">
24+
<source>Hello,</source>
25+
<target state="new">Hello,</target>
26+
<note>key: ibexa.user.invitation.mail.message_title</note>
27+
</trans-unit>
1828
<trans-unit id="54fce872265c3912727c793b582ab71318d2294e" resname="ibexa.user.invitation.mail.subject">
1929
<source>You are invited to join</source>
2030
<target state="new">You are invited to join</target>
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
{% trans_default_domain 'ibexa_forgot_password' %}
1+
{% extends '@ibexadesign/ui/mail/base_mail_template.html.twig' %}
22

3-
{%- block from -%}
4-
{%- endblock from -%}
3+
{% trans_default_domain 'ibexa_forgot_password' %}
54

65
{%- block subject -%}
7-
{{ 'ezplatform.forgot_password.reset_your_password'|trans|desc('Reset your password') }}
6+
{{ 'forgot_user_password.mail.reset_your_password'|trans|desc('Reset your password') }}
87
{%- endblock subject -%}
98

10-
{%- block body -%}
11-
<p>
12-
{{ 'ezplatform.forgot_password.message'|trans({ '%reset_password%': url('ibexa.user.reset_password', {'hashKey': hash_key}) })|raw
13-
|desc('Hello,
14-
<br /><br />
15-
We have received a request to reset the password for your account. Click “reset password” below to choose a new password:
16-
<br /><br />
17-
<a href="%reset_password%">Reset password<a/>
18-
<br /><br />
19-
If you did not request a password reset, please ignore this email, and your password will remain the same.') }}
20-
</p>
21-
{%- endblock body -%}
9+
{%- block mail_message_title_content -%}
10+
{{ 'forgot_user_password.mail.message_title'|trans()|desc('Hello,') }}
11+
{%- endblock mail_message_title_content -%}
12+
13+
{%- block mail_message_content %}
14+
{{ 'forgot_user_password.mail.message'|trans()|desc('We have received a request to reset the password for your account. Click "reset password" below to choose a new password:') }}
15+
{%- endblock mail_message_content %}
16+
17+
{%- block mail_actions_content -%}
18+
{% include '@ibexadesign/ui/mail/action_btn.html.twig' with {
19+
url: url('ibexa.user.reset_password', {
20+
'hashKey': hash_key
21+
}),
22+
label: 'forgot_user_password.mail.reset_password'|trans()|desc('Reset password')
23+
} %}
24+
{%- endblock mail_actions_content -%}
25+
26+
{%- block mail_footer_content -%}
27+
{{ 'forgot_user_password.mail.message_footer'|trans()|desc('If you did not request a password reset, please ignore this email, and your password will remain the same.') }}
28+
{%- endblock mail_footer_content -%}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
{% trans_default_domain 'ibexa_user_invitation' %}
1+
{% extends '@ibexadesign/ui/mail/base_mail_template.html.twig' %}
22

3-
{%- block from -%}
4-
{%- endblock from -%}
3+
{% trans_default_domain 'ibexa_user_invitation' %}
54

65
{%- block subject -%}
76
{{ 'ibexa.user.invitation.mail.subject'|trans|desc('You are invited to join') }}
87
{%- endblock subject -%}
98

10-
{%- block body -%}
11-
<p>
12-
{{ 'ibexa.user.invitation.mail.message'|trans({
13-
'%invite_link%': url('ibexa.user.from_invite.register', {
14-
'inviteHash': invite_hash,
15-
'siteaccess': siteaccess
16-
})
17-
})|raw
18-
|desc('Hello,
19-
Join us at: %invite_link%
20-
') }}
21-
</p>
22-
{%- endblock body -%}
9+
{%- block mail_message_title_content -%}
10+
{{ 'ibexa.user.invitation.mail.message_title'|trans()|desc('Hello,') }}
11+
{%- endblock mail_message_title_content -%}
12+
13+
{%- block mail_message_content -%}
14+
{{ 'ibexa.user.invitation.mail.message'|trans()|desc('Join us at:') }}
15+
{%- endblock mail_message_content -%}
16+
17+
{%- block mail_actions_conten -%}
18+
{% include '@ibexadesign/ui/mail/action_btn.html.twig' with {
19+
url: url('ibexa.user.from_invite.register', {
20+
'inviteHash': invite_hash,
21+
'siteaccess': siteaccess
22+
}),
23+
label: 'ibexa.user.invitation.mail.join'|trans()|desc('Join')
24+
} %}
25+
{%- endblock mail_actions_conten -%}
26+
27+
{%- block mail_footer -%}{%- endblock mail_footer -%}

src/lib/Invitation/MailSender.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Ibexa\Contracts\User\Invitation\InvitationSender;
1414
use Swift_Mailer;
1515
use Swift_Message;
16+
use Swift_Image;
1617
use Twig\Environment;
1718

1819
final class MailSender implements InvitationSender
@@ -49,16 +50,26 @@ public function sendInvitation(Invitation $invitation): void
4950

5051
$subject = $template->renderBlock('subject', []);
5152
$from = $template->renderBlock('from', []) ?: $senderAddress;
53+
54+
$message = (new Swift_Message())
55+
->setSubject($subject)
56+
->setTo($invitation->getEmail());
57+
58+
$mailImagesDir = dirname(__DIR__, 6) . '/public/bundles/ibexaadminui/img/mail/';
59+
$embeddedHeader = $message->embed(Swift_Image::fromPath($mailImagesDir . 'header.jpg'));
60+
$embeddedBtnPrimaryLeftSide = $message->embed(Swift_Image::fromPath($mailImagesDir .'btn_primary_left_side.jpg'));
61+
$embeddedBtnPrimaryRightSide = $message->embed(Swift_Image::fromPath($mailImagesDir .'btn_primary_right_side.jpg'));
62+
5263
$body = $template->renderBlock('body', [
5364
'invite_hash' => $invitation->getHash(),
5465
'siteaccess' => $invitation->getSiteAccessIdentifier(),
5566
'invitation' => $invitation,
67+
'header_path' => $embeddedHeader,
68+
'btn_primary_left_side' => $embeddedBtnPrimaryLeftSide,
69+
'btn_primary_right_side' => $embeddedBtnPrimaryRightSide,
5670
]);
5771

58-
$message = (new Swift_Message())
59-
->setSubject($subject)
60-
->setTo($invitation->getEmail())
61-
->setBody($body, 'text/html');
72+
$message->setBody($body, 'text/html');
6273

6374
if (empty($from) === false) {
6475
$message->setFrom($from);

0 commit comments

Comments
 (0)