From d67cfaa3a44996b174b5d90febbd2e69d0918a86 Mon Sep 17 00:00:00 2001 From: djmaze Date: Mon, 31 May 2021 16:19:01 +0200 Subject: [PATCH] Resolve Issue #93 --- dev/Knoin/Knoin.js | 2 + plugins/login-register/LoginRegister.js | 33 +++++++++++++++ plugins/login-register/index.php | 42 +++++++++++++++++++ plugins/login-register/langs/de-DE.json | 10 +++++ plugins/login-register/langs/en.json | 10 +++++ plugins/login-register/langs/es-ES.json | 10 +++++ plugins/login-register/langs/fr-FR.json | 10 +++++ plugins/login-register/langs/hu-HU.json | 10 +++++ plugins/login-register/langs/nl-NL.json | 10 +++++ plugins/login-register/langs/sv-SE.json | 10 +++++ plugins/login-register/langs/zh-CN.json | 10 +++++ .../Enumerations/PluginPropertyType.php | 14 ++++--- .../Admin/AdminSettingsPluginProperty.html | 4 ++ 13 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 plugins/login-register/LoginRegister.js create mode 100644 plugins/login-register/index.php create mode 100644 plugins/login-register/langs/de-DE.json create mode 100644 plugins/login-register/langs/en.json create mode 100644 plugins/login-register/langs/es-ES.json create mode 100644 plugins/login-register/langs/fr-FR.json create mode 100644 plugins/login-register/langs/hu-HU.json create mode 100644 plugins/login-register/langs/nl-NL.json create mode 100644 plugins/login-register/langs/sv-SE.json create mode 100644 plugins/login-register/langs/zh-CN.json diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 31eb1398e..72f3015e4 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -145,6 +145,8 @@ function buildViewModel(ViewModelClass, vmScreen) { if (vm && ViewType.Popup === position) { vm.registerPopupKeyDown(); } + + dispatchEvent(new CustomEvent('rl-view-model', {detail:vm})); } else { console.log('Cannot find view model position: ' + position); } diff --git a/plugins/login-register/LoginRegister.js b/plugins/login-register/LoginRegister.js new file mode 100644 index 000000000..939095ce3 --- /dev/null +++ b/plugins/login-register/LoginRegister.js @@ -0,0 +1,33 @@ + +(rl => { + if (rl) { + const + forgotUrl = rl.settings.get('forgotPasswordLinkUrl'), + registerUrl = rl.settings.get('registrationLinkUrl'); + + if (forgotUrl || registerUrl) { + addEventListener('rl-view-model', e => { + if (e.detail && 'Login' === e.detail.viewModelTemplateID) { + const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'), + forgot = 'LOGIN/LABEL_FORGOT_PASSWORD', + register = 'LOGIN/LABEL_REGISTRATION'; + if (container) { + let html = ''; + if (forgotUrl) { + html = html + ''; + } + if (registerUrl) { + html = html + ''; + } + container.append(Element.fromHTML('
' + html + '
')); + } + } + }); + } + } + +})(window.rl); diff --git a/plugins/login-register/index.php b/plugins/login-register/index.php new file mode 100644 index 000000000..d602745ce --- /dev/null +++ b/plugins/login-register/index.php @@ -0,0 +1,42 @@ +UseLangs(true); + $this->addJs('LoginRegister.js'); + $this->addHook('filter.app-data', 'FilterAppData'); + } + + public function configMapping() : array + { + return [ + \RainLoop\Plugins\Property::NewInstance("forgot_password_link_url") +// ->SetLabel('TAB_LOGIN/LABEL_FORGOT_PASSWORD_LINK_URL') + ->SetLabel('Forgot password url') + ->SetType(\RainLoop\Enumerations\PluginPropertyType::URL), + \RainLoop\Plugins\Property::NewInstance("registration_link_url") +// ->SetLabel('TAB_LOGIN/LABEL_REGISTRATION_LINK_URL') + ->SetLabel('Register url') + ->SetType(\RainLoop\Enumerations\PluginPropertyType::URL), + ]; + } + + public function FilterAppData($bAdmin, &$aResult) + { + if (!$bAdmin && \is_array($aResult) && empty($aResult['Auth'])) { + $aResult['forgotPasswordLinkUrl'] = \trim($this->Config()->Get('plugin', 'forgot_password_link_url', '')); + $aResult['registrationLinkUrl'] = \trim($this->Config()->Get('plugin', 'registration_link_url', '')); + } + } + +} diff --git a/plugins/login-register/langs/de-DE.json b/plugins/login-register/langs/de-DE.json new file mode 100644 index 000000000..a2ef7cc6f --- /dev/null +++ b/plugins/login-register/langs/de-DE.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Passwort vergessen", + "LABEL_REGISTRATION": "Registrieren" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/en.json b/plugins/login-register/langs/en.json new file mode 100644 index 000000000..20b049871 --- /dev/null +++ b/plugins/login-register/langs/en.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Forgot password", + "LABEL_REGISTRATION": "Register" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/es-ES.json b/plugins/login-register/langs/es-ES.json new file mode 100644 index 000000000..b4bf0354b --- /dev/null +++ b/plugins/login-register/langs/es-ES.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Olvidé mi contraseña", + "LABEL_REGISTRATION": "Registrarse" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/fr-FR.json b/plugins/login-register/langs/fr-FR.json new file mode 100644 index 000000000..3f0c91586 --- /dev/null +++ b/plugins/login-register/langs/fr-FR.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Mot de passe oublié", + "LABEL_REGISTRATION": "S'enregistrer" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/hu-HU.json b/plugins/login-register/langs/hu-HU.json new file mode 100644 index 000000000..87545bf50 --- /dev/null +++ b/plugins/login-register/langs/hu-HU.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Elfelejtett jelszó", + "LABEL_REGISTRATION": "Regisztráció" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/nl-NL.json b/plugins/login-register/langs/nl-NL.json new file mode 100644 index 000000000..69fe6c814 --- /dev/null +++ b/plugins/login-register/langs/nl-NL.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Wachtwoord vergeten", + "LABEL_REGISTRATION": "Registreren" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/sv-SE.json b/plugins/login-register/langs/sv-SE.json new file mode 100644 index 000000000..04d0b0907 --- /dev/null +++ b/plugins/login-register/langs/sv-SE.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "Glömt lösenord", + "LABEL_REGISTRATION": "Registrera" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/plugins/login-register/langs/zh-CN.json b/plugins/login-register/langs/zh-CN.json new file mode 100644 index 000000000..a1c5787c0 --- /dev/null +++ b/plugins/login-register/langs/zh-CN.json @@ -0,0 +1,10 @@ +{ + "LOGIN": { + "LABEL_FORGOT_PASSWORD": "忘记密码", + "LABEL_REGISTRATION": "注册" + }, + "TAB_LOGIN": { + "LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url", + "LABEL_REGISTRATION_LINK_URL": "Register url" + } +} diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Enumerations/PluginPropertyType.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Enumerations/PluginPropertyType.php index 1f6b06fbc..31784f44c 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Enumerations/PluginPropertyType.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Enumerations/PluginPropertyType.php @@ -4,10 +4,12 @@ namespace RainLoop\Enumerations; class PluginPropertyType { - const STRING = 0; - const INT = 1; - const STRING_TEXT = 2; - const PASSWORD = 3; - const SELECTION = 4; - const BOOL = 5; + const + STRING = 0, + INT = 1, + STRING_TEXT = 2, + PASSWORD = 3, + SELECTION = 4, + BOOL = 5, + URL = 6; } diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsPluginProperty.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsPluginProperty.html index 55fdd5274..2c8333e05 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsPluginProperty.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsPluginProperty.html @@ -28,6 +28,10 @@ params: { value: value, label: Label } }"> + + +