Skip to content

IBX-9667: Updated emails template #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 4.6
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/bundle/Controller/PasswordResetController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/bundle/Controller/PasswordResetController.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.1)

Found violation(s) of type: braces

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand Down Expand Up @@ -31,6 +31,7 @@
use Ibexa\User\View\ResetPassword\FormView as UserResetPasswordFormView;
use Ibexa\User\View\ResetPassword\InvalidLinkView;
use Ibexa\User\View\ResetPassword\SuccessView as UserResetPasswordSuccessView;
use Swift_Image;
use Swift_Mailer;
use Swift_Message;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -82,6 +83,7 @@
*/
public function userForgotPasswordAction(Request $request, ?string $reason = null)
{

$form = $this->formFactory->forgotUserPassword();
$form->handleRequest($request);

Expand Down Expand Up @@ -249,12 +251,19 @@

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

$message = (new Swift_Message())
->setSubject($subject)
->setTo($user->email)
->setBody($body, 'text/html');
->setTo($user->email);

$mailImagesDir = dirname(__DIR__, 6) . '/public/bundles/ibexaadminui/img/mail/';
$embeddedHeader = $message->embed(Swift_Image::fromPath($mailImagesDir . 'header.png'));

$body = $template->renderBlock('body', [
'hash_key' => $hashKey,
'header_img_path' => $embeddedHeader,
]);
$message->setBody($body, 'text/html');

if (empty($from) === false) {
$message->setFrom($from);
Expand Down
42 changes: 25 additions & 17 deletions src/bundle/Resources/translations/ibexa_forgot_password.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@
<target state="new">This email is connected with several accounts. Enter your username instead.</target>
<note>key: ezplatform.forgot_password.login</note>
</trans-unit>
<trans-unit id="1af697cb32b6eeeafbf4ca827e766829eac0e992" resname="ezplatform.forgot_password.message">
<source><![CDATA[Hello,
<br /><br />
We have received a request to reset the password for your account. Click “reset password” below to choose a new password:
<br /><br />
<a href="%reset_password%">Reset password<a/>
<br /><br />
If you did not request a password reset, please ignore this email, and your password will remain the same.]]></source>
<target state="new"><![CDATA[Hello,
<br /><br />
We have received a request to reset the password for your account. Click “reset password” below to choose a new password:
<br /><br />
<a href="%reset_password%">Reset password<a/>
<br /><br />
If you did not request a password reset, please ignore this email, and your password will remain the same.]]></target>
<note>key: ezplatform.forgot_password.message</note>
</trans-unit>
<trans-unit id="9d77404b1f40b0458d3b82757b067e15c7dc46e3" resname="ezplatform.forgot_password.reset_your_password">
<source>Reset your password</source>
<target state="new">Reset your password</target>
Expand All @@ -54,6 +37,31 @@
<p>If you reset your password multiple times, only the most recent password reset link will be valid.</p>]]></target>
<note>key: ezplatform.forgot_password.success</note>
</trans-unit>
<trans-unit id="e7b58c781e23a49ce354cdb479f14d6f75ca6e4f" resname="forgot_user_password.mail.message">
<source>We have received a request to reset the password for your account. Click "reset password" below to choose a new password:</source>
<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>
<note>key: forgot_user_password.mail.message</note>
</trans-unit>
<trans-unit id="26ccb574b6cd1e49d40d32d9183db89065138be2" resname="forgot_user_password.mail.message_footer">
<source>If you did not request a password reset, please ignore this email, and your password will remain the same.</source>
<target state="new">If you did not request a password reset, please ignore this email, and your password will remain the same.</target>
<note>key: forgot_user_password.mail.message_footer</note>
</trans-unit>
<trans-unit id="a5ba92910b3dc61efc12c4f42cc869975be98723" resname="forgot_user_password.mail.message_title">
<source>Hello,</source>
<target state="new">Hello,</target>
<note>key: forgot_user_password.mail.message_title</note>
</trans-unit>
<trans-unit id="b7293d1f766a95b50cf3e076c5ef4cd623dc542c" resname="forgot_user_password.mail.reset_password">
<source>Reset password</source>
<target state="new">Reset password</target>
<note>key: forgot_user_password.mail.reset_password</note>
</trans-unit>
<trans-unit id="5fd68a8b7cdaa23771e0e970466b4432642df1d3" resname="forgot_user_password.mail.reset_your_password">
<source>Reset your password</source>
<target state="new">Reset your password</target>
<note>key: forgot_user_password.mail.reset_your_password</note>
</trans-unit>
</body>
</file>
</xliff>
10 changes: 10 additions & 0 deletions src/bundle/Resources/translations/ibexa_user_invitation.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<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>
</header>
<body>
<trans-unit id="07c52e99431e40b768788c64536e4dc12ade0f03" resname="ibexa.user.invitation.mail.join">
<source>Join</source>
<target state="new">Join</target>
<note>key: ibexa.user.invitation.mail.join</note>
</trans-unit>
<trans-unit id="bc254dd11e21f88f3d7b2a1a9c8ab30bb6825702" resname="ibexa.user.invitation.mail.message">
<source xml:space="preserve">Hello,
Join us at: %invite_link%
Expand All @@ -15,6 +20,11 @@
</target>
<note>key: ibexa.user.invitation.mail.message</note>
</trans-unit>
<trans-unit id="56996e20d695f581a1344e83a8c542c7df1a04ec" resname="ibexa.user.invitation.mail.message_title">
<source>Hello,</source>
<target state="new">Hello,</target>
<note>key: ibexa.user.invitation.mail.message_title</note>
</trans-unit>
<trans-unit id="54fce872265c3912727c793b582ab71318d2294e" resname="ibexa.user.invitation.mail.subject">
<source>You are invited to join</source>
<target state="new">You are invited to join</target>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{% trans_default_domain 'ibexa_forgot_password' %}
{% extends '@ibexadesign/ui/mail/base_mail_template.html.twig' %}

{%- block from -%}
{%- endblock from -%}
{% trans_default_domain 'ibexa_forgot_password' %}

{%- block subject -%}
{{ 'ezplatform.forgot_password.reset_your_password'|trans|desc('Reset your password') }}
{{ 'forgot_user_password.mail.reset_your_password'|trans|desc('Reset your password') }}
{%- endblock subject -%}

{%- block body -%}
<p>
{{ 'ezplatform.forgot_password.message'|trans({ '%reset_password%': url('ibexa.user.reset_password', {'hashKey': hash_key}) })|raw
|desc('Hello,
<br /><br />
We have received a request to reset the password for your account. Click “reset password” below to choose a new password:
<br /><br />
<a href="%reset_password%">Reset password<a/>
<br /><br />
If you did not request a password reset, please ignore this email, and your password will remain the same.') }}
</p>
{%- endblock body -%}
{%- block mail_message_title_content -%}
{{ 'forgot_user_password.mail.message_title'|trans()|desc('Hello,') }}
{%- endblock mail_message_title_content -%}

{%- block mail_message_content %}
{{ '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:') }}
{%- endblock mail_message_content %}

{%- block mail_actions_content -%}
{% include '@ibexadesign/ui/mail/action_btn.html.twig' with {
url: url('ibexa.user.reset_password', {
'hashKey': hash_key
}),
label: 'forgot_user_password.mail.reset_password'|trans()|desc('Reset password')
} %}
{%- endblock mail_actions_content -%}

{%- block mail_footer_content -%}
{{ '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.') }}
{%- endblock mail_footer_content -%}
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{% trans_default_domain 'ibexa_user_invitation' %}
{% extends '@ibexadesign/ui/mail/base_mail_template.html.twig' %}

{%- block from -%}
{%- endblock from -%}
{% trans_default_domain 'ibexa_user_invitation' %}

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

{%- block body -%}
<p>
{{ 'ibexa.user.invitation.mail.message'|trans({
'%invite_link%': url('ibexa.user.from_invite.register', {
'inviteHash': invite_hash,
'siteaccess': siteaccess
})
})|raw
|desc('Hello,
Join us at: %invite_link%
') }}
</p>
{%- endblock body -%}
{%- block mail_message_title_content -%}
{{ 'ibexa.user.invitation.mail.message_title'|trans()|desc('Hello,') }}
{%- endblock mail_message_title_content -%}

{%- block mail_message_content -%}
{{ 'ibexa.user.invitation.mail.message'|trans()|desc('Join us at:') }}
{%- endblock mail_message_content -%}

{%- block mail_actions_conten -%}
{% include '@ibexadesign/ui/mail/action_btn.html.twig' with {
url: url('ibexa.user.from_invite.register', {
'inviteHash': invite_hash,
'siteaccess': siteaccess
}),
label: 'ibexa.user.invitation.mail.join'|trans()|desc('Join')
} %}
{%- endblock mail_actions_conten -%}

{%- block mail_footer -%}{%- endblock mail_footer -%}
19 changes: 15 additions & 4 deletions src/lib/Invitation/MailSender.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check warning on line 1 in src/lib/Invitation/MailSender.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.1)

Found violation(s) of type: concat_space

Check warning on line 1 in src/lib/Invitation/MailSender.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.1)

Found violation(s) of type: no_whitespace_in_blank_line

Check warning on line 1 in src/lib/Invitation/MailSender.php

View workflow job for this annotation

GitHub Actions / Run code style check (8.1)

Found violation(s) of type: ordered_imports

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand All @@ -13,6 +13,7 @@
use Ibexa\Contracts\User\Invitation\InvitationSender;
use Swift_Mailer;
use Swift_Message;
use Swift_Image;
use Twig\Environment;

final class MailSender implements InvitationSender
Expand Down Expand Up @@ -49,16 +50,26 @@

$subject = $template->renderBlock('subject', []);
$from = $template->renderBlock('from', []) ?: $senderAddress;

$message = (new Swift_Message())
->setSubject($subject)
->setTo($invitation->getEmail());

$mailImagesDir = dirname(__DIR__, 6) . '/public/bundles/ibexaadminui/img/mail/';
$embeddedHeader = $message->embed(Swift_Image::fromPath($mailImagesDir . 'header.jpg'));
$embeddedBtnPrimaryLeftSide = $message->embed(Swift_Image::fromPath($mailImagesDir .'btn_primary_left_side.jpg'));
$embeddedBtnPrimaryRightSide = $message->embed(Swift_Image::fromPath($mailImagesDir .'btn_primary_right_side.jpg'));

$body = $template->renderBlock('body', [
'invite_hash' => $invitation->getHash(),
'siteaccess' => $invitation->getSiteAccessIdentifier(),
'invitation' => $invitation,
'header_path' => $embeddedHeader,
'btn_primary_left_side' => $embeddedBtnPrimaryLeftSide,
'btn_primary_right_side' => $embeddedBtnPrimaryRightSide,
]);

$message = (new Swift_Message())
->setSubject($subject)
->setTo($invitation->getEmail())
->setBody($body, 'text/html');
$message->setBody($body, 'text/html');

if (empty($from) === false) {
$message->setFrom($from);
Expand Down
Loading