From c7e3e87ea470c25a0b39a5d1e9c8ae39ba475ed5 Mon Sep 17 00:00:00 2001 From: Martin Grossmann Date: Tue, 17 Dec 2024 11:36:30 +0100 Subject: [PATCH] [framework] added missing migration to create admin reset password mail template (#3654) --- src/Migrations/Version20241212064226.php | 92 +++++++++++++++++++ src/Resources/translations/dataFixtures.cs.po | 6 ++ src/Resources/translations/dataFixtures.en.po | 6 ++ 3 files changed, 104 insertions(+) create mode 100644 src/Migrations/Version20241212064226.php diff --git a/src/Migrations/Version20241212064226.php b/src/Migrations/Version20241212064226.php new file mode 100644 index 0000000000..e12e22af79 --- /dev/null +++ b/src/Migrations/Version20241212064226.php @@ -0,0 +1,92 @@ +createMailTemplateIfNotExist(ResetPasswordMail::MAIL_TEMPLATE_NAME); + + foreach ($this->getAllDomainIds() as $domainId) { + $domainLocale = $this->getDomainLocale($domainId); + + $this->updateMailTemplate( + ResetPasswordMail::MAIL_TEMPLATE_NAME, + t('Administrator reset password request', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale), + t('Dear administrator.

' + . 'You can set a new password following this link: {new_password_url}', [], Translator::DATA_FIXTURES_TRANSLATION_DOMAIN, $domainLocale), + $domainId, + ); + } + } + + /** + * @param string $mailTemplateName + */ + private function createMailTemplateIfNotExist( + string $mailTemplateName, + ): void { + foreach ($this->getAllDomainIds() as $domainId) { + $mailTemplateCount = $this->sql( + 'SELECT count(*) FROM mail_templates WHERE name = :mailTemplateName and domain_id = :domainId', + [ + 'mailTemplateName' => $mailTemplateName, + 'domainId' => $domainId, + ], + )->fetchOne(); + + if ($mailTemplateCount !== 0) { + continue; + } + + $this->sql( + 'INSERT INTO mail_templates (name, domain_id, send_mail) VALUES (:mailTemplateName, :domainId, :sendMail)', + [ + 'mailTemplateName' => $mailTemplateName, + 'domainId' => $domainId, + 'sendMail' => true, + ], + ); + } + } + + /** + * @param string $mailTemplateName + * @param string $subject + * @param string $body + * @param int $domainId + */ + private function updateMailTemplate(string $mailTemplateName, string $subject, string $body, int $domainId): void + { + $this->sql( + 'UPDATE mail_templates SET subject = :subject, body = :body WHERE name = :mailTemplateName AND domain_id = :domainId', + [ + 'subject' => $subject, + 'body' => $body, + 'mailTemplateName' => $mailTemplateName, + 'domainId' => $domainId, + ], + ); + } + + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + */ + public function down(Schema $schema): void + { + } +} diff --git a/src/Resources/translations/dataFixtures.cs.po b/src/Resources/translations/dataFixtures.cs.po index bef548350a..b32295b4b9 100644 --- a/src/Resources/translations/dataFixtures.cs.po +++ b/src/Resources/translations/dataFixtures.cs.po @@ -16,6 +16,12 @@ msgstr "

Platba pro objednávku číslo {number} proběhla úspěšně.
Payment for order number {number} has failed.

Please contact us to resolve the issue.

" msgstr "

Platba pro objednávku číslo {number} nebyla úspěšná.

Prosím kontaktujte nás pro vyřešení problému.

" +msgid "Administrator reset password request" +msgstr "Požadavek na resetování hesla administrátora" + +msgid "Dear administrator.

You can set a new password following this link: {new_password_url}" +msgstr "Vážený administrátore.

Můžete nastavit nové heslo následujícím odkazem: {new_password_url}" + msgid "New product inquiry received" msgstr "Byla přijata nová poptávka produktu" diff --git a/src/Resources/translations/dataFixtures.en.po b/src/Resources/translations/dataFixtures.en.po index cef65066ff..c2e8e2221c 100644 --- a/src/Resources/translations/dataFixtures.en.po +++ b/src/Resources/translations/dataFixtures.en.po @@ -16,6 +16,12 @@ msgstr "" msgid "

Payment for order number {number} has failed.

Please contact us to resolve the issue.

" msgstr "" +msgid "Administrator reset password request" +msgstr "" + +msgid "Dear administrator.

You can set a new password following this link: {new_password_url}" +msgstr "" + msgid "New product inquiry received" msgstr ""