From d06d7b4c1b4b85bcff54fb08a7cdff95ea8518ef Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 10 Sep 2023 18:58:34 +0000 Subject: [PATCH] update --- Admin/Install/Messages.install.json | 47 ++- Admin/Install/Messages.php | 6 + Admin/Install/db.json | 508 ++++++++++++++++++++++++++-- Admin/Install/settings.php | 7 + Controller/ApiController.php | 124 +++++-- Models/SettingsEnum.php | 2 + 6 files changed, 626 insertions(+), 68 deletions(-) diff --git a/Admin/Install/Messages.install.json b/Admin/Install/Messages.install.json index 83f1b8f..22d7bfe 100755 --- a/Admin/Install/Messages.install.json +++ b/Admin/Install/Messages.install.json @@ -9,13 +9,13 @@ "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

", - "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" + "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

", - "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" + "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" } }, "send": false @@ -30,13 +30,13 @@ "l11n": { "en": { "subject": "Account recovery", - "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

", - "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" + "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": "Account recovery", - "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

", - "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" + "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

", + "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" } }, "send": false @@ -51,13 +51,34 @@ "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

", - "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" + "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

", - "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" + "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" + } + }, + "send": false + }, + { + "type": "email_template", + "from": "", + "to": "", + "cc": "", + "bcc": "", + "ishtml": true, + "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

", + "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

", + "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" } }, "send": false diff --git a/Admin/Install/Messages.php b/Admin/Install/Messages.php index c8960a5..ab699a6 100755 --- a/Admin/Install/Messages.php +++ b/Admin/Install/Messages.php @@ -66,6 +66,12 @@ class Messages 'content' => (string) $messages['email_template'][2]['id'], 'module' => 'Admin', ], + [ + 'id' => null, + 'name' => SettingsEnum::LOGIN_MAIL_RESET_PASSWORD_TEMPLATE, + 'content' => (string) $messages['email_template'][3]['id'], + 'module' => 'Admin', + ], ]; $response = new HttpResponse(); diff --git a/Admin/Install/db.json b/Admin/Install/db.json index d7309f2..90bf209 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -37,6 +37,50 @@ } } }, + "language": { + "name": "language", + "fields": { + "language_id": { + "name": "language_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "language_name": { + "name": "language_name", + "type": "VARCHAR(100)", + "null": false + }, + "language_native": { + "name": "language_native", + "type": "VARCHAR(100)", + "null": false + }, + "language_639_1": { + "name": "language_639_1", + "type": "VARCHAR(2)", + "null": false, + "unique": true + }, + "language_639_2T": { + "name": "language_639_2T", + "type": "VARCHAR(3)", + "null": false, + "unique": true + }, + "language_639_2B": { + "name": "language_639_2B", + "type": "VARCHAR(3)", + "null": false + }, + "language_639_3": { + "name": "language_639_3", + "type": "VARCHAR(10)", + "null": false + } + } + }, "address": { "name": "address", "fields": { @@ -103,47 +147,232 @@ } } }, - "language": { - "name": "language", + "address_attr_type": { + "name": "address_attr_type", "fields": { - "language_id": { - "name": "language_id", + "address_attr_type_id": { + "name": "address_attr_type_id", "type": "INT", "null": false, "primary": true, "autoincrement": true }, - "language_name": { - "name": "language_name", - "type": "VARCHAR(100)", + "address_attr_type_name": { + "name": "address_attr_type_name", + "type": "VARCHAR(255)", + "null": false, + "unique": true + }, + "address_attr_type_datatype": { + "name": "address_attr_type_datatype", + "type": "INT(11)", "null": false }, - "language_native": { - "name": "language_native", - "type": "VARCHAR(100)", + "address_attr_type_fields": { + "name": "address_attr_type_fields", + "type": "INT(11)", "null": false }, - "language_639_1": { - "name": "language_639_1", + "address_attr_type_custom": { + "name": "address_attr_type_custom", + "type": "TINYINT(1)", + "null": false + }, + "address_attr_type_required": { + "description": "Every address must have this attribute type if set to true.", + "name": "address_attr_type_required", + "type": "TINYINT(1)", + "null": false + }, + "address_attr_type_pattern": { + "description": "This is a regex validation pattern.", + "name": "address_attr_type_pattern", + "type": "VARCHAR(255)", + "null": false + } + } + }, + "address_attr_type_l11n": { + "name": "address_attr_type_l11n", + "fields": { + "address_attr_type_l11n_id": { + "name": "address_attr_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "address_attr_type_l11n_title": { + "name": "address_attr_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "address_attr_type_l11n_type": { + "name": "address_attr_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "address_attr_type", + "foreignKey": "address_attr_type_id" + }, + "address_attr_type_l11n_lang": { + "name": "address_attr_type_l11n_lang", "type": "VARCHAR(2)", "null": false, - "unique": true - }, - "language_639_2T": { - "name": "language_639_2T", - "type": "VARCHAR(3)", + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "address_attr_value": { + "name": "address_attr_value", + "fields": { + "address_attr_value_id": { + "name": "address_attr_value_id", + "type": "INT", "null": false, - "unique": true + "primary": true, + "autoincrement": true }, - "language_639_2B": { - "name": "language_639_2B", - "type": "VARCHAR(3)", + "address_attr_value_default": { + "name": "address_attr_value_default", + "type": "TINYINT(1)", "null": false }, - "language_639_3": { - "name": "language_639_3", - "type": "VARCHAR(10)", + "address_attr_value_valueStr": { + "name": "address_attr_value_valueStr", + "type": "VARCHAR(255)", + "null": true, + "default": null + }, + "address_attr_value_valueInt": { + "name": "address_attr_value_valueInt", + "type": "INT(11)", + "null": true, + "default": null + }, + "address_attr_value_valueDec": { + "name": "address_attr_value_valueDec", + "type": "DECIMAL(19,5)", + "null": true, + "default": null + }, + "address_attr_value_valueDat": { + "name": "address_attr_value_valueDat", + "type": "DATETIME", + "null": true, + "default": null + }, + "address_attr_value_unit": { + "name": "address_attr_value_unit", + "type": "VARCHAR(255)", "null": false + }, + "address_attr_value_deptype": { + "name": "address_attr_value_deptype", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "address_attr_type", + "foreignKey": "address_attr_type_id" + }, + "address_attr_value_depvalue": { + "name": "address_attr_value_depvalue", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "address_attr_value", + "foreignKey": "address_attr_value_id" + } + } + }, + "address_attr_value_l11n": { + "name": "address_attr_value_l11n", + "fields": { + "address_attr_value_l11n_id": { + "name": "address_attr_value_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "address_attr_value_l11n_title": { + "name": "address_attr_value_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "address_attr_value_l11n_value": { + "name": "address_attr_value_l11n_value", + "type": "INT(11)", + "null": false, + "foreignTable": "address_attr_value", + "foreignKey": "address_attr_value_id" + }, + "address_attr_value_l11n_lang": { + "name": "address_attr_value_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "address_attr_default": { + "name": "address_attr_default", + "fields": { + "address_attr_default_id": { + "name": "address_attr_default_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "address_attr_default_type": { + "name": "address_attr_default_type", + "type": "INT(11)", + "null": false, + "foreignTable": "address_attr_type", + "foreignKey": "address_attr_type_id" + }, + "address_attr_default_value": { + "name": "address_attr_default_value", + "type": "INT(11)", + "null": false, + "foreignTable": "address_attr_value", + "foreignKey": "address_attr_value_id" + } + } + }, + "address_attr": { + "name": "address_attr", + "fields": { + "address_attr_id": { + "name": "address_attr_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "address_attr_address": { + "name": "address_attr_address", + "type": "INT(11)", + "null": false, + "foreignTable": "address", + "foreignKey": "address_id" + }, + "address_attr_type": { + "name": "address_attr_type", + "type": "INT(11)", + "null": false, + "foreignTable": "address_attr_type", + "foreignKey": "address_attr_type_id" + }, + "address_attr_value": { + "name": "address_attr_value", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "address_attr_value", + "foreignKey": "address_attr_value_id" } } }, @@ -628,7 +857,7 @@ "null": false }, "unit_attr_type_required": { - "description": "Every item must have this attribute type if set to true.", + "description": "Every unit must have this attribute type if set to true.", "name": "unit_attr_type_required", "type": "TINYINT(1)", "null": false @@ -1119,6 +1348,235 @@ } } }, + "account_attr_type": { + "name": "account_attr_type", + "fields": { + "account_attr_type_id": { + "name": "account_attr_type_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_attr_type_name": { + "name": "account_attr_type_name", + "type": "VARCHAR(255)", + "null": false, + "unique": true + }, + "account_attr_type_datatype": { + "name": "account_attr_type_datatype", + "type": "INT(11)", + "null": false + }, + "account_attr_type_fields": { + "name": "account_attr_type_fields", + "type": "INT(11)", + "null": false + }, + "account_attr_type_custom": { + "name": "account_attr_type_custom", + "type": "TINYINT(1)", + "null": false + }, + "account_attr_type_required": { + "description": "Every account must have this attribute type if set to true.", + "name": "account_attr_type_required", + "type": "TINYINT(1)", + "null": false + }, + "account_attr_type_pattern": { + "description": "This is a regex validation pattern.", + "name": "account_attr_type_pattern", + "type": "VARCHAR(255)", + "null": false + } + } + }, + "account_attr_type_l11n": { + "name": "account_attr_type_l11n", + "fields": { + "account_attr_type_l11n_id": { + "name": "account_attr_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_attr_type_l11n_title": { + "name": "account_attr_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "account_attr_type_l11n_type": { + "name": "account_attr_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "account_attr_type", + "foreignKey": "account_attr_type_id" + }, + "account_attr_type_l11n_lang": { + "name": "account_attr_type_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "account_attr_value": { + "name": "account_attr_value", + "fields": { + "account_attr_value_id": { + "name": "account_attr_value_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_attr_value_default": { + "name": "account_attr_value_default", + "type": "TINYINT(1)", + "null": false + }, + "account_attr_value_valueStr": { + "name": "account_attr_value_valueStr", + "type": "VARCHAR(255)", + "null": true, + "default": null + }, + "account_attr_value_valueInt": { + "name": "account_attr_value_valueInt", + "type": "INT(11)", + "null": true, + "default": null + }, + "account_attr_value_valueDec": { + "name": "account_attr_value_valueDec", + "type": "DECIMAL(19,5)", + "null": true, + "default": null + }, + "account_attr_value_valueDat": { + "name": "account_attr_value_valueDat", + "type": "DATETIME", + "null": true, + "default": null + }, + "account_attr_value_unit": { + "name": "account_attr_value_unit", + "type": "VARCHAR(255)", + "null": false + }, + "account_attr_value_deptype": { + "name": "account_attr_value_deptype", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "account_attr_type", + "foreignKey": "account_attr_type_id" + }, + "account_attr_value_depvalue": { + "name": "account_attr_value_depvalue", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "account_attr_value", + "foreignKey": "account_attr_value_id" + } + } + }, + "account_attr_value_l11n": { + "name": "account_attr_value_l11n", + "fields": { + "account_attr_value_l11n_id": { + "name": "account_attr_value_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_attr_value_l11n_title": { + "name": "account_attr_value_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "account_attr_value_l11n_value": { + "name": "account_attr_value_l11n_value", + "type": "INT(11)", + "null": false, + "foreignTable": "account_attr_value", + "foreignKey": "account_attr_value_id" + }, + "account_attr_value_l11n_lang": { + "name": "account_attr_value_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "account_attr_default": { + "name": "account_attr_default", + "fields": { + "account_attr_default_id": { + "name": "account_attr_default_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_attr_default_type": { + "name": "account_attr_default_type", + "type": "INT(11)", + "null": false, + "foreignTable": "account_attr_type", + "foreignKey": "account_attr_type_id" + }, + "account_attr_default_value": { + "name": "account_attr_default_value", + "type": "INT(11)", + "null": false, + "foreignTable": "account_attr_value", + "foreignKey": "account_attr_value_id" + } + } + }, + "account_attr": { + "name": "account_attr", + "fields": { + "account_attr_id": { + "name": "account_attr_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_attr_account": { + "name": "account_attr_account", + "type": "INT(11)", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "account_attr_type": { + "name": "account_attr_type", + "type": "INT(11)", + "null": false, + "foreignTable": "account_attr_type", + "foreignKey": "account_attr_type_id" + }, + "account_attr_value": { + "name": "account_attr_value", + "type": "INT(11)", + "null": true, + "default": null, + "foreignTable": "account_attr_value", + "foreignKey": "account_attr_value_id" + } + } + }, "account_external": { "name": "account_external", "fields": { diff --git a/Admin/Install/settings.php b/Admin/Install/settings.php index 392a23e..99b0c95 100755 --- a/Admin/Install/settings.php +++ b/Admin/Install/settings.php @@ -91,6 +91,13 @@ return [ 'pattern' => '/\\d*/', 'module' => 'Admin', ], + [ + 'type' => 'setting', + 'name' => SettingsEnum::LOGIN_MAIL_RESET_PASSWORD_TEMPLATE, + 'content' => '', + 'pattern' => '/\\d*/', + 'module' => 'Admin', + ], [ 'type' => 'setting', 'name' => SettingsEnum::DEFAULT_LOCALIZATION, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 88d936e..7575668 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -269,11 +269,6 @@ final class ApiController extends Controller account: $account->id ); - $emailSettings = $this->app->appSettings->get( - names: SettingsEnum::MAIL_SERVER_ADDR, - module: 'Admin' - ); - if ((int) $forgotten[SettingsEnum::LOGIN_FORGOTTEN_COUNT]->content > 3) { $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->set($request->uri->__toString(), [ @@ -288,12 +283,54 @@ final class ApiController extends Controller $handler = $this->setUpServerMailHandler(); $resetLink = UriFactory::build('{/base}/reset?user=' . $account->id . '&token=' . $token); - $mail = new Email(); - $mail->setFrom($emailSettings->content); - $mail->addTo($account->getEmail(), \trim($account->name1 . ' ' . $account->name2 . ' ' . $account->name3)); - $mail->subject = 'Jingga: Forgot Password'; - $mail->body = ''; - $mail->msgHTML('Please reset your password at: ' . $resetLink . ''); + /** @var \Model\Setting[] $emailSettings */ + $emailSettings = $this->app->appSettings->get( + names: [SettingsEnum::MAIL_SERVER_ADDR, SettingsEnum::LOGIN_MAIL_FORGOT_PASSWORD_TEMPLATE], + module: 'Admin' + ); + + /** @var \Modules\Messages\Models\Email $mail */ + $mail = EmailMapper::get() + ->with('l11n') + ->where('id', (int) $emailSettings[SettingsEnum::LOGIN_MAIL_FORGOT_PASSWORD_TEMPLATE]->content) + ->where('l11n/language', $response->header->l11n->language) + ->execute(); + + $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); + $mail->addTo($account->email); + + // @todo: load default l11n if no translation is available + $mailL11n = $mail->getL11nByLanguage($response->header->l11n->language); + + $mail->subject = $mailL11n->subject; + + // @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 + ); + + $handler->send($mail); $this->app->appSettings->set([ [ @@ -328,7 +365,7 @@ final class ApiController extends Controller } */ - $handler->send($mail); + // $handler->send($mail); $response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true); $response->set($request->uri->__toString(), [ @@ -386,29 +423,56 @@ final class ApiController extends Controller AccountMapper::update()->execute($account); + $handler = $this->setUpServerMailHandler(); + /** @var \Model\Setting[] $emailSettings */ $emailSettings = $this->app->appSettings->get( - names: [ - SettingsEnum::MAIL_SERVER_ADDR, - SettingsEnum::MAIL_SERVER_CERT, - SettingsEnum::MAIL_SERVER_KEY, - SettingsEnum::MAIL_SERVER_KEYPASS, - SettingsEnum::MAIL_SERVER_TLS, - ], - module: self::NAME + names: [SettingsEnum::MAIL_SERVER_ADDR, SettingsEnum::LOGIN_MAIL_FORGOT_PASSWORD_TEMPLATE], + module: 'Admin' ); - $handler = $this->setUpServerMailHandler(); - $loginLink = UriFactory::build('{/base}/{/backend}'); + /** @var \Modules\Messages\Models\Email $mail */ + $mail = EmailMapper::get() + ->with('l11n') + ->where('id', (int) $emailSettings[SettingsEnum::LOGIN_MAIL_FORGOT_PASSWORD_TEMPLATE]->content) + ->where('l11n/language', $response->header->l11n->language) + ->execute(); - $mail = new Email(); - $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content, 'Jingga'); - $mail->addTo($account->getEmail(), \trim($account->name1 . ' ' . $account->name2 . ' ' . $account->name3)); - $mail->subject = 'Jingga: Password reset'; - $mail->body = ''; - $mail->msgHTML('Your new password: ' . $pass . '' - . "\n\n" - . 'Please remember to change your password after logging in!'); + $mail->setFrom($emailSettings[SettingsEnum::MAIL_SERVER_ADDR]->content); + $mail->addTo($account->email); + + // @todo: load default l11n if no translation is available + $mailL11n = $mail->getL11nByLanguage($response->header->l11n->language); + + $mail->subject = $mailL11n->subject; + + // @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 + ); + + $handler->send($mail); $this->app->appSettings->set([ [ diff --git a/Models/SettingsEnum.php b/Models/SettingsEnum.php index 2bc5241..0ff0728 100755 --- a/Models/SettingsEnum.php +++ b/Models/SettingsEnum.php @@ -69,6 +69,8 @@ abstract class SettingsEnum extends Enum public const LOGIN_MAIL_FAILED_TEMPLATE = '1000000108'; + public const LOGIN_MAIL_RESET_PASSWORD_TEMPLATE = '1000000109'; + /* Mail server settings */ public const MAIL_SERVER_OUT = '1000000201';