diff --git a/Admin/Install/Messages.install.json b/Admin/Install/Messages.install.json index 22d7bfe..7693f5d 100755 --- a/Admin/Install/Messages.install.json +++ b/Admin/Install/Messages.install.json @@ -9,12 +9,12 @@ "l11n": { "en": { "subject": "Registration confirmation", - "body": "Registration Confirmation

Registration Confirmation

Dear {user_name},

Thank you for registering for our service. Your account has been successfully created.

Your username is: {user_name}

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Registration Confirmation

Registration Confirmation

Dear {user_name},

Thank you for registering for our service. Your account has been successfully created.

Your username is: {user_name}

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Dear {user_name},\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: {user_name}\n\nTo get started, please click on the following confirmation link: {confirmation_link}\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" }, "de": { "subject": "Registrierungsbestätigung", - "body": "Registrierungsbestätigung

Registrierungsbestätigung

Sehr geehrte/r {user_name},

Vielen Dank für Ihre Registrierung bei unserem Service. Ihr Konto wurde erfolgreich erstellt.

Ihr Benutzername lautet: {user_name}

Um loszulegen, klicken Sie bitte auf den folgenden Bestätigungslink:

Bestätigen

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Registrierungsbestätigung

Registrierungsbestätigung

Sehr geehrte/r {user_name},

Vielen Dank für Ihre Registrierung bei unserem Service. Ihr Konto wurde erfolgreich erstellt.

Ihr Benutzername lautet: {user_name}

Um loszulegen, klicken Sie bitte auf den folgenden Bestätigungslink:

Bestätigen

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Sehr geehrte/r {user_name},\n\nvielen Dank für Ihre Registrierung bei unserem Service. Ihr Konto wurde erfolgreich erstellt.\n\nIhr Benutzername lautet: {user_name}\n\nUm loszulegen, klicken Sie bitte auf den folgenden Bestätigungslink: {confirmation_link}\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" } }, @@ -30,12 +30,12 @@ "l11n": { "en": { "subject": "Account recovery", - "body": "Account Recovery

Account Recovery

Dear {user_name},

We received a request to recover your account.

To reset your password, please click on the following recovery link:

Reset Password

If you did not request this account recovery, please contact our support team immediately.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Account Recovery

Account Recovery

Dear {user_name},

We received a request to recover your account.

To reset your password, please click on the following recovery link:

Reset Password

If you did not request this account recovery, please contact our support team immediately.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Dear {user_name},\n\nWe received a request to recover your account.\n\nTo reset your password, please click on the following recovery link: {reset_link}.\n\nIf you did not request this account recovery, please contact our support team immediately.\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" }, "de": { "subject": "Kontowiederherstellung", - "body": "Kontowiederherstellung

Kontowiederherstellung

Lieber {user_name},

Wir haben eine Anfrage erhalten, um Ihr Konto wiederherzustellen.

Um Ihr Passwort zurückzusetzen, klicken Sie bitte auf den folgenden Wiederherstellungslink:

Passwort zurücksetzen

Wenn Sie diese Kontowiederherstellung nicht angefordert haben, kontaktieren Sie bitte umgehend unser Support-Team.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Kontowiederherstellung

Kontowiederherstellung

Lieber {user_name},

Wir haben eine Anfrage erhalten, um Ihr Konto wiederherzustellen.

Um Ihr Passwort zurückzusetzen, klicken Sie bitte auf den folgenden Wiederherstellungslink:

Passwort zurücksetzen

Wenn Sie diese Kontowiederherstellung nicht angefordert haben, kontaktieren Sie bitte umgehend unser Support-Team.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Sehr geehrte/r {user_name},\n\nWir haben eine Anfrage erhalten, um Ihr Konto wiederherzustellen.\n\nUm Ihr Passwort zurückzusetzen, klicken Sie bitte auf den folgenden Wiederherstellungslink: {reset_link}.\n\nWenn Sie diese Kontowiederherstellung nicht angefordert haben, wenden Sie sich bitte umgehend an unser Support-Team.\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" } }, @@ -51,12 +51,12 @@ "l11n": { "en": { "subject": "Failed login", - "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" }, "de": { "subject": "Failed login", - "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Registration Confirmation

Registration Confirmation

Dear [Name],

Thank you for registering for our service. Your account has been successfully created.

Your username is: [Username]

To get started, please click on the following confirmation link:

Confirm

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Dear [Name],\n\nThank you for registering for our service. Your account has been successfully created.\n\nYour username is: [Username]\n\nTo get started, please click on the following confirmation link: [Login Link].\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" } }, @@ -72,12 +72,12 @@ "l11n": { "en": { "subject": "Account recovery", - "body": "Account Recovery

Account Recovery

Dear {user_name},

We received a request to recover your account.

Your new password is:

{new_password}

If you did not request this account recovery, please contact our support team immediately.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Account Recovery

Account Recovery

Dear {user_name},

We received a request to recover your account.

Your new password is:

{new_password}

If you did not request this account recovery, please contact our support team immediately.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Dear {user_name},\n\nWe received a request to recover your account.\n\nYour new password is: {new_password}.\n\nIf you did not request this account recovery, please contact our support team immediately.\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" }, "de": { "subject": "Kontowiederherstellung", - "body": "Kontowiederherstellung

Kontowiederherstellung

Lieber {user_name},

Wir haben eine Anfrage erhalten, um Ihr Konto wiederherzustellen.

Ihr neues Passwort lautet:

{new_password}

Wenn Sie diese Kontowiederherstellung nicht angefordert haben, kontaktieren Sie bitte umgehend unser Support-Team.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Kontowiederherstellung

Kontowiederherstellung

Lieber {user_name},

Wir haben eine Anfrage erhalten, um Ihr Konto wiederherzustellen.

Ihr neues Passwort lautet:

{new_password}

Wenn Sie diese Kontowiederherstellung nicht angefordert haben, kontaktieren Sie bitte umgehend unser Support-Team.

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Sehr geehrte/r {user_name},\n\nWir haben eine Anfrage erhalten, um Ihr Konto wiederherzustellen.\n\nIhr neues Passwort lautet: {new_password}.\n\nWenn Sie diese Kontowiederherstellung nicht angefordert haben, wenden Sie sich bitte umgehend an unser Support-Team.\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" } }, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 4305c00..09f35d7 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -294,6 +294,10 @@ final class ApiController extends Controller module: 'Admin' ); + if (empty($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content)) { + return; + } + /** @var \Modules\Messages\Models\Email $mail */ $mail = EmailMapper::get() ->with('l11n') @@ -304,36 +308,18 @@ final class ApiController extends Controller $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); $mail->addTo($account->email); - // @todo load default l11n if no translation is available + // @todo Implement a model reading system which allows to define alternative conditions/wheres + // https://github.com/Karaka-Management/phpOMS/issues/365 $mailL11n = $mail->getL11nByLanguage($response->header->l11n->language); $mail->subject = $mailL11n->subject; + $mail->body = $mailL11n->body; + $mail->bodyAlt = $mailL11n->bodyAlt; - // @todo improve, the /tld link could be api.myurl.com which of course is not the url of the respective app. - // Maybe store the uri in the $app model? or store all urls in the config file - $mail->body = \str_replace( - [ - '{reset_link}', - '{user_name}', - ], - [ - $resetLink, - $account->login, - ], - $mailL11n->body - ); - - $mail->bodyAlt = \str_replace( - [ - '{reset_link}', - '{user_name}', - ], - [ - $resetLink, - $account->login, - ], - $mailL11n->bodyAlt - ); + $mail->template = [ + '{reset_link}' => $resetLink, + '{user_name}' => $account->login, + ]; $handler->send($mail); @@ -436,6 +422,10 @@ final class ApiController extends Controller module: 'Admin' ); + if (empty($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content)) { + return; + } + /** @var \Modules\Messages\Models\Email $mail */ $mail = EmailMapper::get() ->with('l11n') @@ -446,36 +436,18 @@ final class ApiController extends Controller $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); $mail->addTo($account->email); - // @todo load default l11n if no translation is available + // @todo Implement a model reading system which allows to define alternative conditions/wheres + // https://github.com/Karaka-Management/phpOMS/issues/365 $mailL11n = $mail->getL11nByLanguage($response->header->l11n->language); $mail->subject = $mailL11n->subject; + $mail->body = $mailL11n->body; + $mail->bodyAlt = $mailL11n->bodyAlt; - // @todo improve, the /tld link could be api.myurl.com which of course is not the url of the respective app. - // Maybe store the uri in the $app model? or store all urls in the config file - $mail->body = \str_replace( - [ - '{new_password}', - '{user_name}', - ], - [ - $pass, - $account->login, - ], - $mailL11n->body - ); - - $mail->bodyAlt = \str_replace( - [ - '{new_password}', - '{user_name}', - ], - [ - $pass, - $account->login, - ], - $mailL11n->bodyAlt - ); + $mail->template = [ + '{new_password}' => $pass, + '{user_name}' => $account->login, + ]; $handler->send($mail); @@ -1873,6 +1845,10 @@ final class ApiController extends Controller module: 'Admin' ); + if (empty($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content)) { + return; + } + /** @var \Modules\Messages\Models\Email $mail */ $mail = EmailMapper::get() ->with('l11n') @@ -1883,40 +1859,20 @@ final class ApiController extends Controller $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); $mail->addTo((string) $request->getData('email')); - // @todo load default l11n if no translation is available + // @todo Implement a model reading system which allows to define alternative conditions/wheres + // https://github.com/Karaka-Management/phpOMS/issues/365 $mailL11n = $mail->getL11nByLanguage($response->header->l11n->language); $mail->subject = $mailL11n->subject; + $mail->body = $mailL11n->body; + $mail->bodyAlt = $mailL11n->bodyAlt; - // @todo improve, the /tld link could be api.myurl.com which of course is not the url of the respective app. - // Maybe store the uri in the $app model? or store all urls in the config file - $mail->body = \str_replace( - [ - '{confirmation_link}', - '{user_name}', - ], - [ - UriFactory::hasQuery('/' . \strtolower($app->name)) - ? UriFactory::build('{/' . \strtolower($app->name) . '}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()) - : UriFactory::build('{/tld}/{/lang}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()), - $account->login, - ], - $mailL11n->body - ); - - $mail->bodyAlt = \str_replace( - [ - '{confirmation_link}', - '{user_name}', - ], - [ - UriFactory::hasQuery('/' . \strtolower($app->name)) - ? UriFactory::build('{/' . \strtolower($app->name) . '}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()) - : UriFactory::build('{/tld}/{/lang}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()), - $account->login, - ], - $mailL11n->bodyAlt - ); + $mail->template = [ + '{confirmation_link}' => UriFactory::hasQuery('/' . \strtolower($app->name)) + ? UriFactory::build('{/' . \strtolower($app->name) . '}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()) + : UriFactory::build('{/tld}/{/lang}/' . \strtolower($app->name) . '/signup/confirmation?hash=' . $dataChange->getHash()), + '{user_name}' => $account->login, + ]; $handler->send($mail); } @@ -1990,7 +1946,9 @@ final class ApiController extends Controller * @return void * * @api - * @todo maybe move to job/workflow??? This feels very much like a job/event especially if we make the 'type' an event-trigger + * + * @question Consider to re-implement the apiDataChange function as workflow + * https://github.com/Karaka-Management/oms-Admin/issues/31 * * @since 1.0.0 */ @@ -3345,8 +3303,6 @@ final class ApiController extends Controller * * @return array * - * @todo Implement API validation function - * * @since 1.0.0 */ private function validateGroupPermissionDelete(RequestAbstract $request) : array @@ -3404,8 +3360,6 @@ final class ApiController extends Controller * * @return array * - * @todo Implement API validation function - * * @since 1.0.0 */ private function validateAccountPermissionDelete(RequestAbstract $request) : array @@ -3525,8 +3479,6 @@ final class ApiController extends Controller * * @return array * - * @todo Implement API validation function - * * @since 1.0.0 */ private function validateContactDelete(RequestAbstract $request) : array @@ -3687,8 +3639,6 @@ final class ApiController extends Controller * * @return array * - * @todo Implement API validation function - * * @since 1.0.0 */ private function validateAddressDelete(RequestAbstract $request) : array