diff --git a/ajax/frontend/register.php b/ajax/frontend/register.php index e02480c0e554c05e8c2f5c68fc2741f9fe1a8c7f..4603e8def831254fa300445a7dad5308dbf405ac 100644 --- a/ajax/frontend/register.php +++ b/ajax/frontend/register.php @@ -11,6 +11,8 @@ * @throws QUI\Exception */ +use QUI\FrontendUsers\Handler; + QUI::$Ajax->registerFunction( 'package_quiqqer_frontend-users_ajax_frontend_register', function ($registrar, $data, $registrars, $isSignUpRegistration = false) { @@ -27,11 +29,10 @@ function ($registrar, $data, $registrars, $isSignUpRegistration = false) { ]); $_POST = array_merge($_POST, json_decode($data, true)); - $_POST['registration'] = 1; $_POST['registrar'] = $registrar; - $Registrar = \QUI\FrontendUsers\Handler::getInstance()->getRegistrarByHash($registrar); + $Registrar = Handler::getInstance()->getRegistrarByHash($registrar); try { $status = $Registration->create(); diff --git a/bin/frontend/controls/Registration.css b/bin/frontend/controls/Registration.css new file mode 100644 index 0000000000000000000000000000000000000000..d88819b31b8b476d5169a5610c6de5cadb51073e --- /dev/null +++ b/bin/frontend/controls/Registration.css @@ -0,0 +1,82 @@ +.quiqqer-frontendUsers-controls-registration { + display: inline-block; + position: relative; + width: 100%; +} + +.quiqqer-frontendUsers-controls-registration-registrar { + display: inline-block; + position: relative; + width: 100%; +} + +.quiqqer-frontendUsers-controls-registration-or { + border-top: 1px solid #CFD2D2; + clear: both; + color: #CFD2D2; + float: left; + line-height: 30px; + margin: 2rem 0 1.5rem; + text-align: center; + position: relative; + height: 10px; + width: 100%; +} + +.quiqqer-frontendUsers-controls-registration-or-text { + background: #fff; + color: #666666; + font-size: 16px; + line-height: 30px; + padding: 0 10px; + position: relative; + text-align: center; + top: -15px; +} + +.quiqqer-frontendUsers-controls-registration .quiqqer-frontend-social-button { + width: 100%; +} + +.quiqqer-registration-trial-registrar-submit button { + width: 100%; +} + +.quiqqer-frontendUsers-autoRedirect { + margin-top: 10px; +} + +.quiqqer-frontendUsers-controls-registration-locked { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + z-index: 10; + background: rgba(255, 255, 255, 0.7); +} + +.quiqqer-frontendUsers-controls-registration-termsOfUse { + display: inline-block; + margin: 1rem 0; + width: 100%; +} + +.quiqqer-frontendUsers-controls-registration-termsOfUse label { + cursor: pointer; + display: inline-block; + width: 100%; +} + +.quiqqer-frontendUsers-controls-registration-termsOfUse label > input { + float: left; +} + +.quiqqer-frontendUsers-controls-registration-termsOfUse label > span { + float: left; + width: calc(100% - 30px); +} + +.quiqqer-frontendUsers-controls-registration-nextlinks { + margin: 10px 0 0 0 !important; +} diff --git a/bin/frontend/controls/Registration.js b/bin/frontend/controls/Registration.js index 07553c5f68b1cbe83f29c52ae6b4e51a04cf1a0f..25faddfa7bcb4485f93a08fd54930eb7dce8978c 100644 --- a/bin/frontend/controls/Registration.js +++ b/bin/frontend/controls/Registration.js @@ -15,17 +15,19 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ 'package/quiqqer/controls/bin/site/Window', 'qui/utils/Form', 'Locale', - 'Ajax' + 'Ajax', + + 'css!package/quiqqer/frontend-users/bin/frontend/controls/Registration.css' ], function (QUI, QUIControl, QUILoader, QUISiteWindow, QUIFormUtils, QUILocale, QUIAjax) { "use strict"; - var lg = 'quiqqer/frontend-users'; + const lg = 'quiqqer/frontend-users'; return new Class({ Extends: QUIControl, - Type : 'package/quiqqer/frontend-users/bin/frontend/controls/Registration', + Type: 'package/quiqqer/frontend-users/bin/frontend/controls/Registration', Binds: [ '$onImport', @@ -39,8 +41,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ initialize: function (options) { this.parent(options); - this.Loader = null; - this.$TermsOfUseCheckBox = null; + this.Loader = null; this.addEvents({ onImport: this.$onImport @@ -51,8 +52,8 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ * event: on import */ $onImport: function () { - var self = this, - Elm = this.getElm(), + const self = this, + Elm = this.getElm(), forms = Elm.getElements('form.quiqqer-frontendUsers-controls-registration-registrar'); QUI.fireEvent('quiqqerFrontendUsersRegisterStart', [this]); @@ -66,11 +67,11 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ }); // Terms Of Use / Privacy Policy - var TermsOfUseElm = Elm.getElement('.quiqqer-frontendUsers-controls-registration-termsOfUse'); + const TermsOfUseElm = Elm.getElement('.quiqqer-frontendUsers-controls-registration-termsOfUse'); if (TermsOfUseElm) { - var TermsOfUseLink = TermsOfUseElm.getElement('a.quiqqer-frontendusers-termsofuse-link'); - var PrivacyPolicyLink = TermsOfUseElm.getElement('a.quiqqer-frontendusers-privacypolicy-link'); + const TermsOfUseLink = TermsOfUseElm.getElement('a.quiqqer-frontendusers-termsofuse-link'); + const PrivacyPolicyLink = TermsOfUseElm.getElement('a.quiqqer-frontendusers-privacypolicy-link'); if (TermsOfUseLink) { TermsOfUseLink.addEvent('click', function (event) { @@ -78,10 +79,10 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ new QUISiteWindow({ closeButtonText: QUILocale.get(lg, 'btn.close'), - showTitle : true, - project : QUIQQER_PROJECT.name, - lang : QUIQQER_PROJECT.lang, - id : TermsOfUseElm.get('data-termsofusesiteid') + showTitle: true, + project: QUIQQER_PROJECT.name, + lang: QUIQQER_PROJECT.lang, + id: TermsOfUseElm.get('data-termsofusesiteid') }).open(); }); } @@ -92,20 +93,16 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ new QUISiteWindow({ showTitle: true, - project : QUIQQER_PROJECT.name, - lang : QUIQQER_PROJECT.lang, - id : TermsOfUseElm.get('data-privacypolicysiteid') + project: QUIQQER_PROJECT.name, + lang: QUIQQER_PROJECT.lang, + id: TermsOfUseElm.get('data-privacypolicysiteid') }).open(); }); } - - this.$TermsOfUseCheckBox = Elm.getElement( - '.quiqqer-frontendUsers-controls-registration-termsOfUse input[type="checkbox"]' - ); } // Redirect - var RedirectElm = Elm.getElement( + const RedirectElm = Elm.getElement( '.quiqqer-frontendUsers-redirect' ); @@ -115,8 +112,8 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ return; } - var url = RedirectElm.get('data-url'); - var instant = RedirectElm.get('data-instant') === "1"; + const url = RedirectElm.get('data-url'); + const instant = RedirectElm.get('data-instant') === "1"; if (instant) { window.location = url; @@ -138,16 +135,20 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ $sendForm: function (Form) { this.Loader.show(); - var self = this, + const self = this, formData = QUIFormUtils.getFormData(Form); - if (this.$TermsOfUseCheckBox) { - formData.termsOfUseAccepted = this.$TermsOfUseCheckBox.checked; + const termsOfUse = this.getElm().getElement( + '.quiqqer-frontendUsers-controls-registration-termsOfUse input[type="checkbox"]' + ); + + if (termsOfUse) { + formData.termsOfUseAccepted = termsOfUse.checked; } return new Promise(function (resolve, reject) { QUIAjax.post('package_quiqqer_frontend-users_ajax_frontend_register', function (Data) { - var Elm = self.getElm(); + const Elm = self.getElm(); if (Data.userActivated) { QUI.fireEvent('quiqqerFrontendUsersUserActivate', [ @@ -157,11 +158,11 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ ]); } - var Container = new Element('div', { + const Container = new Element('div', { html: Data.html }); - var Registration = Container.getElement( + const Registration = Container.getElement( '[data-qui="package/quiqqer/frontend-users/bin/frontend/controls/Registration"]' ); @@ -178,11 +179,11 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/Registration', [ resolve(); }, reject); }, { - 'package' : 'quiqqer/frontend-users', - registrar : Form.get('data-registrar'), - data : JSON.encode(formData), + 'package': 'quiqqer/frontend-users', + registrar: Form.get('data-registrar'), + data: JSON.encode(formData), registrars: self.getAttribute('registrars'), - onError : reject + onError: reject }); }); } diff --git a/bin/frontend/controls/login/Login.js b/bin/frontend/controls/login/Login.js index 0b98ad3824aad38501219b312e255f4f4ee22b91..0ff17c77f60abb0cec7b3c972f80d4aca4bec03c 100644 --- a/bin/frontend/controls/login/Login.js +++ b/bin/frontend/controls/login/Login.js @@ -28,7 +28,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ 'Ajax', 'Locale' -], function(QUI, QUIControl, QUILoader, QUIFormUtils, ResendActivationLinkBtn, URI, QUIAjax, QUILocale) { +], function (QUI, QUIControl, QUILoader, QUIFormUtils, ResendActivationLinkBtn, URI, QUIAjax, QUILocale) { 'use strict'; var lg = 'quiqqer/frontend-users'; @@ -62,7 +62,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ submitauth: false // md5sum of classname of authenticator that is *immediately* submitted upon control load }, - initialize: function(options) { + initialize: function (options) { this.parent(options); this.$Elm = null; @@ -80,7 +80,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ * * @return {HTMLDivElement} */ - create: function() { + create: function () { this.$Elm = this.parent(); this.$Elm.addClass('quiqqer-frontendUsers-login'); @@ -101,7 +101,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * event: on import */ - $onImport: function() { + $onImport: function () { this.Loader.inject(this.$Elm); if (this.getAttribute('showLoader')) { @@ -121,14 +121,14 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * event: on import */ - $onInject: function() { + $onInject: function () { var self = this; if (this.getAttribute('showLoader')) { this.Loader.show(); } - QUIAjax.get('package_quiqqer_frontend-users_ajax_frontend_login_getControl', function(result) { + QUIAjax.get('package_quiqqer_frontend-users_ajax_frontend_login_getControl', function (result) { const Ghost = new Element('div', { html: result }); @@ -160,10 +160,10 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * parse qui controls for loading */ - $parseQuiControls: function() { + $parseQuiControls: function () { var self = this; - QUI.parse(this.getElm()).then(function() { + QUI.parse(this.getElm()).then(function () { var Login = self.getElm().querySelector('[data-name="login-container"]'); // already logged in @@ -179,9 +179,9 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ Login.setStyle('display', null); Login.setStyle('positino', 'relative'); - self.getElm().getElements('form[name="quiqqer-fu-login-email"]').addEvent('submit', function(event) { + self.getElm().getElements('form[name="quiqqer-fu-login-email"]').addEvent('submit', function (event) { event.stop(); - self.authByEmail().catch(function(e) { + self.authByEmail().catch(function (e) { // nothing }); }); @@ -200,21 +200,21 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ self.getElm().getElements( '[data-name="forgot-password-link"] a' - ).addEvent('click', function(event) { + ).addEvent('click', function (event) { event.stop(); self.openForgottenPassword(); }); self.getElm().getElements( '.quiqqer-fu-login-forget-password-reset [name="cancel"]' - ).addEvent('click', function(event) { + ).addEvent('click', function (event) { event.stop(); self.closeForgottenPassword(); }); self.getElm().getElements( '.quiqqer-fu-login-forget-password-reset [type="submit"]' - ).addEvent('click', function(event) { + ).addEvent('click', function (event) { event.stop(); self.sendForgottenPassword(); }); @@ -237,7 +237,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ moofx(Login).animate({ opacity: 1 }, { - callback: function() { + callback: function () { self.Loader.hide(); self.fireEvent('load', [self]); @@ -276,7 +276,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * Authentication via email */ - authByEmail: function() { + authByEmail: function () { var self = this, Form = this.getElm().querySelector('form[name="quiqqer-fu-login-email"]'); @@ -289,8 +289,8 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ var FormData = QUIFormUtils.getFormData(Form); - return new Promise(function(resolve, reject) { - QUIAjax.post('ajax_users_login', function(result) { + return new Promise(function (resolve, reject) { + QUIAjax.post('ajax_users_login', function (result) { window.QUIQQER_USER = result.user; self.fireEvent('success', [self]); @@ -316,7 +316,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ authenticator: 'QUI\\Users\\Auth\\QUIQQER', globalauth: 1, params: JSON.encode(FormData), - onError: function(e) { + onError: function (e) { self.Loader.hide(); self.fireEvent('userLoginError', [ self, @@ -338,7 +338,9 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ * * @param Form */ - $authBySocial: function(Form) { + $authBySocial: function (Form) { + console.log('$authBySocial', Form); + var self = this; this.fireEvent('authBegin', [this]); @@ -346,7 +348,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ this.$showSocialLoader(Form); - QUIAjax.post('ajax_users_login', function(result) { + QUIAjax.post('ajax_users_login', function (result) { window.QUIQQER_USER = result.user; self.fireEvent('success', [self]); @@ -360,7 +362,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ return; } - QUIAjax.get('package_quiqqer_frontend-users_ajax_frontend_login_getLoginRedirect', function(redirect) { + QUIAjax.get('package_quiqqer_frontend-users_ajax_frontend_login_getLoginRedirect', function (redirect) { if (!self.getAttribute('reload')) { return; } @@ -386,7 +388,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ params: JSON.encode( QUIFormUtils.getFormData(Form) ), - onError: function(e) { + onError: function (e) { self.$hideSocialLoader(Form); self.Loader.hide(); self.fireEvent('userLoginError', [ @@ -406,10 +408,14 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ * * @param Form */ - $showSocialLoader: function(Form) { + $showSocialLoader: function (Form) { var Icon = Form.querySelector('[data-name="social-login-entry-icon"]'); var Loader = Form.querySelector('[data-name="social-login-entry-loader"]'); + if (!Icon || !Loader) { + return; + } + Loader.setStyle('opacity', 0); Loader.setStyle('display', 'inline-block'); @@ -417,7 +423,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ opacity: 0 }, { duration: 250, - callback: function() { + callback: function () { Icon.setStyle('display', 'none'); } }); @@ -434,10 +440,14 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ * * @param Form */ - $hideSocialLoader: function(Form) { + $hideSocialLoader: function (Form) { var Icon = Form.querySelector('[data-name="social-login-entry-icon"]'); var Loader = Form.querySelector('[data-name="social-login-entry-loader"]'); + if (!Icon || !Loader) { + return; + } + Icon.setStyle('opacity', 0); Icon.setStyle('display', 'inline-block'); @@ -451,7 +461,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ opacity: 1 }, { duration: 250, - callback: function() { + callback: function () { Loader.setStyle('display', 'none'); } }); @@ -460,7 +470,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * social authentication */ - $auth: function(event) { + $auth: function (event) { if (clicked) { return; } @@ -478,7 +488,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ Control.click(); clicked = true; // we need that because of control click - (function() { + (function () { clicked = false; }).delay(200); }, @@ -486,14 +496,14 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * on success */ - $onSuccess: function() { + $onSuccess: function () { if (!this.getAttribute('redirect')) { return; } var self = this; - QUIAjax.post('package_quiqqer_frontend-users_ajax_frontend_login_getLoginRedirect', function(result) { + QUIAjax.post('package_quiqqer_frontend-users_ajax_frontend_login_getLoginRedirect', function (result) { if (!self.getAttribute('reload')) { return; } @@ -516,7 +526,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * opens the password forgotten sheet */ - openForgottenPassword: function() { + openForgottenPassword: function () { var Reset = this.getElm().querySelector('[data-name="password-reset"]'); if (!Reset) { @@ -551,7 +561,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ left: 0, opacity: 1 }, { - callback: function() { + callback: function () { } }); @@ -568,7 +578,11 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ * * @param {Object} error */ - $onUserLoginError: function(Control, error) { + $onUserLoginError: function (Control, error) { + if (!this.$Elm) { + console.error(error); + return; + } var ActivationInfoBox = this.$Elm.querySelector('[data-name="activation-info"]'); ActivationInfoBox.set('html', ''); @@ -586,7 +600,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ html: error.getMessage() }); - var showResendError = function() { + var showResendError = function () { MsgElm.set('html', QUILocale.get(lg, 'controls.frontend.Login.resend_activation_mail_error')); MsgElm.removeClass('content-message-attention'); MsgElm.addClass('content-message-error'); @@ -616,10 +630,10 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ new ResendActivationLinkBtn({ email: email, events: { - onResendSuccess: function(Btn) { + onResendSuccess: function (Btn) { Btn.disable(); }, - onResendFail: function(Btn) { + onResendFail: function (Btn) { showResendError(); Btn.enable(); } @@ -636,7 +650,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * close the password reset */ - closeForgottenPassword: function() { + closeForgottenPassword: function () { var Reset = this.getElm().querySelector('[data-name="password-reset"]'); if (!Reset) { @@ -658,7 +672,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ left: -50, opacity: 0 }, { - callback: function() { + callback: function () { Reset.setStyle('display', 'none'); } }); @@ -667,7 +681,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ moofx(Login).animate({ height: LoginInner.offsetHeight }, { - callback: function() { + callback: function () { Login.style.height = null; } }); @@ -677,7 +691,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ /** * send password reset call */ - sendForgottenPassword: function() { + sendForgottenPassword: function () { var self = this, Elm = this.getElm(), PasswordReset = Elm.querySelector('[data-name="password-reset"]'), @@ -692,11 +706,11 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ EmailInput.disabled = true; SubmitBtn.disabled = true; - var showHideMessage = function(Message) { + var showHideMessage = function (Message) { moofx(Section).animate({ opacity: 0 }, { - callback: function() { + callback: function () { Section.setStyle('display', 'none'); } }); @@ -706,14 +720,14 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ top: 0 }, { duration: 200, - callback: function() { - (function() { + callback: function () { + (function () { moofx(Message).animate({ opacity: 0, top: -20 }, { duration: 200, - callback: function() { + callback: function () { Message.destroy(); EmailInput.value = ''; @@ -730,7 +744,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ }); }; - this.$sendPasswordResetConfirmMail(EmailInput.value).then(function() { + this.$sendPasswordResetConfirmMail(EmailInput.value).then(function () { self.Loader.hide(); var Message = new Element('div', { @@ -751,7 +765,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ EmailInput.disabled = false; SubmitBtn.disabled = false; - }, function(e) { + }, function (e) { self.Loader.hide(); var Message = new Element('div', { @@ -783,8 +797,8 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [ * @param {String} email * @return {Promise} */ - $sendPasswordResetConfirmMail: function(email) { - return new Promise(function(resolve, reject) { + $sendPasswordResetConfirmMail: function (email) { + return new Promise(function (resolve, reject) { QUIAjax.post('ajax_users_authenticator_sendPasswordResetConfirmMail', resolve, { email: email, onError: reject, diff --git a/src/QUI/FrontendUsers/Controls/Registration.css b/src/QUI/FrontendUsers/Controls/Registration.css index b7b92ffee1fdb1865021fd53fa0e3c5679277db5..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/src/QUI/FrontendUsers/Controls/Registration.css +++ b/src/QUI/FrontendUsers/Controls/Registration.css @@ -1,60 +0,0 @@ -.quiqqer-frontendUsers-controls-registration { - display: inline-block; - position: relative; - width: 100%; -} - -.quiqqer-frontendUsers-controls-registration-or { - border-top: 1px solid #CFD2D2; - clear: both; - color: #CFD2D2; - float: left; - line-height: 30px; - margin: 50px 0; - text-align: center; - position: relative; - width: 100%; -} - -.quiqqer-frontendUsers-controls-registration-or-text { - color: #666666; - font-size: 16px; - line-height: 30px; - padding: 0 10px; - position: relative; - text-align: center; - top: -15px; -} - -.quiqqer-frontendUsers-autoRedirect { - margin-top: 10px; -} - -.quiqqer-frontendUsers-controls-registration-locked { - height: 100%; - left: 0px; - position: absolute; - top: 0px; - width: 100%; - z-index: 10; - background: rgba(255, 255, 255, 0.7); -} - -.quiqqer-frontendUsers-controls-registration-termsOfUse { - float: left; - margin-bottom: 50px; - width: 100%; -} - -.quiqqer-frontendUsers-controls-registration-termsOfUse label { - float: left; - width: 100%; -} - -.quiqqer-frontendUsers-controls-registration-termsOfUse label > input { - float: left; -} - -.quiqqer-frontendUsers-controls-registration-nextlinks { - margin: 10px 0 0 0 !important; -} \ No newline at end of file diff --git a/src/QUI/FrontendUsers/Controls/Registration.html b/src/QUI/FrontendUsers/Controls/Registration.html index 53c96b0aeeca7deea5bc955ca9e2046e2de586d3..04f0b872eb419fdb76ff8127a54807ba4f428257 100644 --- a/src/QUI/FrontendUsers/Controls/Registration.html +++ b/src/QUI/FrontendUsers/Controls/Registration.html @@ -11,7 +11,7 @@ require(['qui/QUI'], function(QUI) { (function() { QUI.fireEvent('quiqqerFrontendUsersUserActivate', [ - {$User->getId()}, + '{$User->getUUID()}', '{$registrarHash}', '{$registrarType}' ]); @@ -21,97 +21,108 @@ {/if} {if $success} -<div class="content-message-success"> - {if !$instantRedirect} - {$Registrar->getSuccessMessage()} - {/if} - {if $redirectUrl || $instantReload} - <div class="quiqqer-frontendUsers-redirect" - {if !empty($redirectUrl)}data-url="{$redirectUrl}"{/if} - data-instant="{if $instantRedirect}1{else}0{/if}" - data-reload="{if $instantReload}1{else}0{/if}" - > - {if !$instantRedirect && !$instantReload} - {locale group="quiqqer/frontend-users" var="control.registration.auto_redirect" url=$redirectUrl} + <div class="content-message-success"> + {if !$instantRedirect} + {$registrar->getSuccessMessage()} + {/if} + {if $redirectUrl || $instantReload} + <div class="quiqqer-frontendUsers-redirect" + {if !empty($redirectUrl)}data-url="{$redirectUrl}"{/if} + data-instant="{if $instantRedirect}1{else}0{/if}" + data-reload="{if $instantReload}1{else}0{/if}" + > + {if !$instantRedirect && !$instantReload} + {locale group="quiqqer/frontend-users" var="control.registration.auto_redirect" url=$redirectUrl} + {/if} + </div> + {elseif $nextLinksText} + <p class="quiqqer-frontendUsers-controls-registration-nextlinks"> + {$nextLinksText} + </p> {/if} </div> - {elseif $nextLinksText} - <p class="quiqqer-frontendUsers-controls-registration-nextlinks"> - {$nextLinksText} - </p> - {/if} -</div> {if $Login} {$Login->create()} {/if} -{template_event name="quiqqer::frontendUsers::registrationSuccess"} - -{elseif $Registrar && isset($registrationStatus) && $registrationStatus === 2} -<div class="content-message-information"> - {$Registrar->getPendingMessage()} -</div> - -{template_event name="quiqqer::frontendUsers::registrationPending"} - + {template_event name="quiqqer::frontendUsers::registrationSuccess"} +{elseif $registrar && isset($registrationStatus) && $registrationStatus === 2} + <div class="content-message-information"> + {$registrar->getPendingMessage()} + </div> + {template_event name="quiqqer::frontendUsers::registrationPending"} {else} {if isset($error) && !$redirectUrl} - <div class="content-message-error"> - {$error} - </div> - - {template_event name="quiqqer::frontendUsers::registrationError"} - + <div class="content-message-error"> + {$error} + </div> + {template_event name="quiqqer::frontendUsers::registrationError"} {/if} {if !isset($isGeneralError)} - {if $Registrars->isEmpty()} + {if $registrars->isEmpty() || $mailRegistrars->isEmpty()} <div class="content-message-information"> {locale group="quiqqer/frontend-users" var="control.registration.registration_disabled"} </div> {else} <div class="quiqqer-frontendUsers-controls-registration"> - {foreach $Registrars as $Registrar} + {foreach $mailRegistrars as $registrar} <form action="" method="POST" class="quiqqer-frontendUsers-controls-registration-registrar" - data-registrar="{$Registrar->getHash()}" + data-registrar="{$registrar->getHash()}" > {if $showRegistrarTitle} <header> - <h2>{$Registrar->getTitle()}</h2> + <h2>{$registrar->getTitle()}</h2> </header> {/if} - {$Registrar->getControl()->create()} + {$registrar->getControl()->create()} - <input type="hidden" name="registrar" value="{$Registrar->getHash()}"/> + <input type="hidden" name="registrar" value="{$registrar->getHash()}"/> <input type="hidden" name="registration" value="1"/> <input type="hidden" name="registration_id" value="{$registrationId}"/> </form> + {/foreach} - {if $Registrar !== $Registrars->last()} + {if !$registrars->isEmpty() && !$mailRegistrars->isEmpty()} <div class="quiqqer-frontendUsers-controls-registration-or"> - <span class="quiqqer-frontendUsers-controls-registration-or-text control-background"> - {locale group="quiqqer/frontend-users" var="control.registration.or"} - </span> + <span class="quiqqer-frontendUsers-controls-registration-or-text"> + OR + </span> </div> {/if} + + {foreach $registrars as $registrar} + <form action="" + method="POST" + class="quiqqer-frontendUsers-controls-registration-registrar" + data-registrar="{$registrar->getHash()}" + > + {if $showRegistrarTitle} + <header> + <h2>{$registrar->getTitle()}</h2> + </header> + {/if} + + {$registrar->getControl()->create()} + + <input type="hidden" name="registrar" value="{$registrar->getHash()}"/> + <input type="hidden" name="registration" value="1"/> + <input type="hidden" name="registration_id" value="{$registrationId}"/> + </form> {/foreach} {if $termsOfUseRequired} <div class="quiqqer-frontendUsers-controls-registration-termsOfUse" {if $termsOfUseSiteId} data-termsofusesiteid="{$termsOfUseSiteId}"{/if} - {if $privacyPolicySiteId} data-privacypolicysiteid="{$privacyPolicySiteId}"{/if} + {if $privacyPolicySiteId} data-privacypolicysiteid="{$privacyPolicySiteId}"{/if} > - <p> <label> - <span> - {$termsOfUseLabel} - </span> - <input type="checkbox"{if $termsOfUseAcctepted} checked{/if}/> + <input type="checkbox"{if $termsOfUseAccepted} checked{/if}/> + <span>{$termsOfUseLabel}</span> </label> - </p> </div> {/if} </div> diff --git a/src/QUI/FrontendUsers/Controls/Registration.php b/src/QUI/FrontendUsers/Controls/Registration.php index 7b1a1e438132c8042df81ac6933dcc952da368bc..fa7d69d84ea09a40c15c583daaa2196bd7a5a933 100644 --- a/src/QUI/FrontendUsers/Controls/Registration.php +++ b/src/QUI/FrontendUsers/Controls/Registration.php @@ -89,10 +89,10 @@ public function __construct(array $attributes = []) public function getBody(): string { $Engine = QUI::getTemplateManager()->getEngine(); - $RegistrarHandler = QUI\FrontendUsers\Handler::getInstance(); - $Registrars = $this->getRegistrars(); - $registrationSettings = $RegistrarHandler->getRegistrationSettings(); - $CurrentRegistrar = $this->isCurrentlyExecuted(); + $registrarHandler = QUI\FrontendUsers\Handler::getInstance(); + $registrars = $this->getRegistrars(); + $registrationSettings = $registrarHandler->getRegistrationSettings(); + $currentRegistrar = $this->isCurrentlyExecuted(); $registrationStatus = false; $projectLang = QUI::getRewrite()->getProject()->getLang(); @@ -108,7 +108,6 @@ public function getBody(): string 'registrationStatus' => $registrationStatus ]); } catch (QUI\FrontendUsers\Exception\UserAlreadyExistsException $Exception) { - QUI\System\Log::writeDebugException($Exception); $Engine->assign('error', $Exception->getMessage()); } catch (QUI\FrontendUsers\Exception $Exception) { QUI\System\Log::write( @@ -116,13 +115,11 @@ public function getBody(): string QUI\System\Log::LEVEL_WARNING, [ 'process' => 'registration', - 'registrar' => $CurrentRegistrar ? $CurrentRegistrar->getTitle() : 'unknown' + 'registrar' => $currentRegistrar ? $currentRegistrar->getTitle() : 'unknown' ], 'frontend-users' ); - QUI\System\Log::writeDebugException($Exception); - $Engine->assign('error', $Exception->getMessage()); } catch (Exception $Exception) { QUI\System\Log::writeException($Exception); @@ -137,8 +134,8 @@ public function getBody(): string // check for errors $status = $this->getAttribute('status'); - if ($status === $RegistrarHandler::REGISTRATION_STATUS_ERROR && $CurrentRegistrar) { - $Engine->assign('error', $CurrentRegistrar->getErrorMessage()); + if ($status === $registrarHandler::REGISTRATION_STATUS_ERROR && $currentRegistrar) { + $Engine->assign('error', $currentRegistrar->getErrorMessage()); } elseif ($status === 'error') { $Engine->assign([ 'error' => QUI::getLocale()->get( @@ -150,9 +147,8 @@ public function getBody(): string } // determine success - $success = $CurrentRegistrar - && ($status === 'success' - || $registrationStatus === $RegistrarHandler::REGISTRATION_STATUS_SUCCESS); + $success = $currentRegistrar && + ($status === 'success' || $registrationStatus === $registrarHandler::REGISTRATION_STATUS_SUCCESS); // redirect directives $redirectUrl = false; @@ -169,7 +165,7 @@ public function getBody(): string $registrationSettings['autoLoginOnActivation'] ) { // instantly redirect (only used on auto-login) - $loginSettings = $RegistrarHandler->getLoginSettings(); + $loginSettings = $registrarHandler->getLoginSettings(); $redirectOnLogin = $loginSettings['redirectOnLogin']; $Project = $this->getProject(); $projectLang = $Project->getLang(); @@ -206,7 +202,7 @@ public function getBody(): string if (!$success && $loggedIn) { switch ($registrationSettings['visitRegistrationSiteBehaviour']) { case 'showProfile': - $ProfileSite = $RegistrarHandler->getProfileSite(QUI::getRewrite()->getProject()); + $ProfileSite = $registrarHandler->getProfileSite(QUI::getRewrite()->getProject()); if ($ProfileSite) { header('Location: ' . $ProfileSite->getUrlRewritten()); @@ -311,9 +307,38 @@ public function getBody(): string } // Sort registrars by display position - $Registrars->sort(function ($RegistrarA, $RegistrarB) use ($RegistrarHandler) { - $settingsA = $RegistrarHandler->getRegistrarSettings(get_class($RegistrarA)); - $settingsB = $RegistrarHandler->getRegistrarSettings(get_class($RegistrarB)); + $mailRegistrars = $registrars->filter(function ($Registrar) use ($registrarHandler) { + if (class_exists('QUI\Registration\Trial\Registrar')) { + if ($Registrar instanceof QUI\Registration\Trial\Registrar) { + return true; + } + } + + if ($Registrar instanceof QUI\FrontendUsers\Registrars\Email\Registrar) { + return true; + } + + return false; + }); + + // remove mail registrars + $registrars = $registrars->filter(function ($Registrar) use ($registrarHandler) { + if (class_exists('QUI\Registration\Trial\Registrar')) { + if ($Registrar instanceof QUI\Registration\Trial\Registrar) { + return false; + } + } + + if ($Registrar instanceof QUI\FrontendUsers\Registrars\Email\Registrar) { + return false; + } + + return true; + }); + + $registrars->sort(function ($RegistrarA, $RegistrarB) use ($registrarHandler) { + $settingsA = $registrarHandler->getRegistrarSettings(get_class($RegistrarA)); + $settingsB = $registrarHandler->getRegistrarSettings(get_class($RegistrarB)); $displayPositionA = (int)$settingsA['displayPosition']; $displayPositionB = (int)$settingsB['displayPosition']; @@ -321,21 +346,24 @@ public function getBody(): string }); if (!empty($_REQUEST['registrar'])) { - $Registrar = $RegistrarHandler->getRegistrarByHash($_REQUEST['registrar']); + $registrar = $registrarHandler->getRegistrarByHash($_REQUEST['registrar']); - if ($Registrar) { + if ($registrar) { $Engine->assign([ 'fireUserActivationEvent' => true, 'User' => QUI::getUserBySession(), - 'registrarHash' => $Registrar->getHash(), - 'registrarType' => str_replace('\\', '\\\\', $Registrar->getType()) + 'registrarHash' => $registrar->getHash(), + 'registrarType' => str_replace('\\', '\\\\', $registrar->getType()) ]); } } + // Mail Registrar + $Engine->assign([ - 'Registrars' => $Registrars, - 'Registrar' => $CurrentRegistrar, + 'registrars' => $registrars, + 'mailRegistrars' => $mailRegistrars, + 'registrar' => $currentRegistrar, 'success' => $success, 'redirectUrl' => $redirectUrl, 'instantRedirect' => $instantRedirect, @@ -343,7 +371,7 @@ public function getBody(): string 'Login' => $Login, 'termsOfUseLabel' => $termsOfUseLabel, 'termsOfUseRequired' => $termsOfUseRequired, - 'termsOfUseAcctepted' => !empty($_POST['termsOfUseAccepted']), + 'termsOfUseAccepted' => !empty($_POST['termsOfUseAccepted']), 'registrationId' => $this->id, 'showRegistrarTitle' => $this->getAttribute('showRegistrarTitle'), 'nextLinksText' => $success ? RegistrationUtils::getFurtherLinksText() : false @@ -397,7 +425,7 @@ public function getRegisteredUser(): ?QUI\Interfaces\Users\User * * @return bool|QUI\FrontendUsers\RegistrarInterface */ - protected function isCurrentlyExecuted(): bool|QUI\FrontendUsers\RegistrarInterface + protected function isCurrentlyExecuted(): bool | QUI\FrontendUsers\RegistrarInterface { $FrontendUsers = QUI\FrontendUsers\Handler::getInstance(); $Registrar = $this->getAttribute('Registrar');