From 98cd15e91f13d3b7f4db097ddb2e03554e35a6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Mon, 22 Jun 2020 21:06:15 +0200 Subject: [PATCH] MAPG-164 show application's name from env variable --- .env.example | 1 + mail/signup-noconfirm.html | 8 ++++---- mail/signup.html | 10 +++++----- src/Controller/LoginController.php | 6 ++---- src/Mailing/Mail.php | 7 +++++++ views/admin/map_editor.php | 2 +- views/error/404.php | 2 +- views/game.php | 2 +- views/templates/footer.php | 2 +- views/templates/header.php | 4 ++-- views/templates/main_header.php | 2 +- 11 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index b263030..77ca310 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ +APP_NAME=MapQuiz DEV=1 DB_HOST=mariadb DB_USER=mapguesser diff --git a/mail/signup-noconfirm.html b/mail/signup-noconfirm.html index 8c00ae0..dba50fa 100644 --- a/mail/signup-noconfirm.html +++ b/mail/signup-noconfirm.html @@ -1,9 +1,9 @@ Hi,

-You recently signed up on MapGuesser with this Google account ({{EMAIL}}). +You recently signed up on {{APP_NAME}} with this Google account ({{EMAIL}}).

-Have fun on MapGuesser! +Have fun on {{APP_NAME}}!

Regards,
-MapGuesser
-{{BASE_URL}} +{{APP_NAME}}
+{{BASE_URL}} diff --git a/mail/signup.html b/mail/signup.html index 629d774..dcb3849 100644 --- a/mail/signup.html +++ b/mail/signup.html @@ -1,14 +1,14 @@ Hi,

-You recently signed up on MapGuesser with this email address ({{EMAIL}}). To activate your account, please click on the following link:
+You recently signed up on {{APP_NAME}} with this email address ({{EMAIL}}). To activate your account, please click on the following link:
{{ACTIVATE_LINK}}

-If you did not sign up on MapGuesser or changed your mind, no further action is required, your email address will be deleted soon.
+If you did not sign up on {{APP_NAME}} or changed your mind, no further action is required, your email address will be deleted soon.
However if you want to immediately delete it, please click on the following link:
{{CANCEL_LINK}}

-Have fun on MapGuesser! +Have fun on {{APP_NAME}}!

Regards,
-MapGuesser
-{{BASE_URL}} +{{APP_NAME}}
+{{BASE_URL}} diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php index 5223a54..c0c740f 100644 --- a/src/Controller/LoginController.php +++ b/src/Controller/LoginController.php @@ -373,12 +373,11 @@ class LoginController { $mail = new Mail(); $mail->addRecipient($email); - $mail->setSubject('Welcome to MapGuesser - Activate your account'); + $mail->setSubject('Welcome to ' . $_ENV['APP_NAME'] . ' - Activate your account'); $mail->setBodyFromTemplate('signup', [ 'EMAIL' => $email, 'ACTIVATE_LINK' => $this->request->getBase() . '/'. \Container::$routeCollection->getRoute('signup.activate')->generateLink(['token' => $token]), 'CANCEL_LINK' => $this->request->getBase() . '/' . \Container::$routeCollection->getRoute('signup.cancel')->generateLink(['token' => $token]), - 'BASE_URL' => $this->request->getBase(), ]); $mail->send(); } @@ -387,10 +386,9 @@ class LoginController { $mail = new Mail(); $mail->addRecipient($email); - $mail->setSubject('Welcome to MapGuesser'); + $mail->setSubject('Welcome to ' . $_ENV['APP_NAME']); $mail->setBodyFromTemplate('signup-noconfirm', [ 'EMAIL' => $email, - 'BASE_URL' => $this->request->getBase(), ]); $mail->send(); } diff --git a/src/Mailing/Mail.php b/src/Mailing/Mail.php index 0f14b68..383659d 100644 --- a/src/Mailing/Mail.php +++ b/src/Mailing/Mail.php @@ -29,6 +29,13 @@ class Mail { $this->body = file_get_contents(ROOT . '/mail/' . $template . '.html'); + $baseParameters = [ + 'APP_NAME' => $_ENV['APP_NAME'], + 'BASE_URL' => \Container::$request->getBase(), + ]; + + $params = array_merge($baseParameters, $params); + foreach ($params as $key => $param) { $this->body = str_replace('{{' . $key . '}}', $param, $this->body); } diff --git a/views/admin/map_editor.php b/views/admin/map_editor.php index 1452525..cfa60a3 100644 --- a/views/admin/map_editor.php +++ b/views/admin/map_editor.php @@ -17,7 +17,7 @@ $jsFiles = [

MapGuesser + -->

diff --git a/views/error/404.php b/views/error/404.php index 6751fa3..f50146f 100644 --- a/views/error/404.php +++ b/views/error/404.php @@ -1,6 +1,6 @@

404 | Page not found

-

The requested URL was not found on this server. Back to start.

+

The requested URL was not found on this server. Back to start.

\ No newline at end of file diff --git a/views/game.php b/views/game.php index 03abc84..ea72975 100644 --- a/views/game.php +++ b/views/game.php @@ -12,7 +12,7 @@ $jsFiles = [

MapGuesser + -->

diff --git a/views/templates/footer.php b/views/templates/footer.php index ca51b0a..790ac18 100644 --- a/views/templates/footer.php +++ b/views/templates/footer.php @@ -1,5 +1,5 @@

\ No newline at end of file diff --git a/views/templates/header.php b/views/templates/header.php index 11d2c96..32518cf 100644 --- a/views/templates/header.php +++ b/views/templates/header.php @@ -1,8 +1,8 @@

- + MapGuesser + -->

diff --git a/views/templates/main_header.php b/views/templates/main_header.php index bf8404d..b27c91e 100644 --- a/views/templates/main_header.php +++ b/views/templates/main_header.php @@ -3,7 +3,7 @@ - MapGuesser + <?= $_ENV['APP_NAME'] ?>