Add indicator of the activation status in the frontend
authorjoshuaruesweg <ruesweg@woltlab.com>
Fri, 22 May 2020 13:00:41 +0000 (15:00 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Fri, 22 May 2020 13:00:41 +0000 (15:00 +0200)
com.woltlab.wcf/templates/accountManagement.tpl
com.woltlab.wcf/templates/registerActivation.tpl
com.woltlab.wcf/templates/user.tpl
com.woltlab.wcf/templates/userNotice.tpl
wcfsetup/install/files/lib/form/RegisterActivationForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index cc35e9d75f238ceb60f91792500c6f9c742ba13a..bf7285df53de93bd0cde8adc37ed8f8e874dd5f8 100644 (file)
                        
                        {event name='changeEmailFields'}
                        
-                       {if REGISTER_ACTIVATION_METHOD == 1 && $__wcf->getUser()->reactivationCode != 0}
+                       {if REGISTER_ACTIVATION_METHOD & 1 && $__wcf->getUser()->reactivationCode != 0}
                                <dl>
                                        <dt></dt>
                                        <dd>
index 2711ff0a9e4cc3f18929c1973c5e413b59fa4cfd..b7c87f54e2b3c51f2099b3cd76be651df55f1745 100644 (file)
@@ -1,6 +1,6 @@
 {include file='header' __disableAds=true}
 
-{if $__wcf->user->userID && $__wcf->user->activationCode}<p class="info" role="status">{lang}wcf.user.registerActivation.info{/lang}</p>{/if}
+{if $__wcf->user->userID && !$__wcf->user->isEmailConfirmed()}<p class="info" role="status">{lang}wcf.user.registerActivation.info{/lang}</p>{/if}
 
 {include file='formError'}
 
@@ -21,7 +21,7 @@
                <dl{if $errorField == 'activationCode'} class="formError"{/if}>
                        <dt><label for="activationCode">{lang}wcf.user.activationCode{/lang}</label></dt>
                        <dd>
-                               <input type="text" id="activationCode" maxlength="9" name="activationCode" value="{@$activationCode}" required class="medium">
+                               <input type="text" id="activationCode" maxlength="40" name="activationCode" value="{@$activationCode}" required class="medium">
                                {if $errorField == 'activationCode'}
                                        <small class="innerError">
                                                {if $errorType == 'invalid'}{lang}wcf.user.activationCode.error.invalid{/lang}{/if}
index b69b4fad726dc10572cdd76b402b3405c8e82f08..73783be65690e0d7b797130af46c1da47486f62e 100644 (file)
                                                                        {if $__wcf->session->getPermission('admin.user.canDisableAvatar')}<li><a href="#" class="jsButtonUserDisableAvatar">{lang}wcf.user.{if $user->disableAvatar}enable{else}disable{/if}Avatar{/lang}</a></li>{/if}
                                                                        {if $__wcf->session->getPermission('admin.user.canDisableSignature')}<li><a href="#" class="jsButtonUserDisableSignature">{lang}wcf.user.{if $user->disableSignature}enable{else}disable{/if}Signature{/lang}</a></li>{/if}
                                                                        {if MODULE_USER_COVER_PHOTO && $__wcf->session->getPermission('admin.user.canDisableCoverPhoto')}<li><a href="#" class="jsButtonUserDisableCoverPhoto">{lang}wcf.user.{if $user->disableCoverPhoto}enable{else}disable{/if}CoverPhoto{/lang}</a></li>{/if}
-                                                                       {if $__wcf->session->getPermission('admin.user.canEnableUser')}<li><a href="#" class="jsButtonUserEnable">{lang}wcf.acp.user.{if $user->activationCode}enable{else}disable{/if}{/lang}</a></li>{/if}
+                                                                       {if $__wcf->session->getPermission('admin.user.canEnableUser')}<li><a href="#" class="jsButtonUserEnable">{lang}wcf.acp.user.{if $user->isActivated())}enable{else}disable{/if}{/lang}</a></li>{/if}
                                                                        
                                                                        {if $__wcf->session->getPermission('admin.general.canUseAcp') && $__wcf->session->getPermission('admin.user.canEditUser')}<li><a href="{link controller='UserEdit' object=$user isACP=true}{/link}" class="jsUserInlineEditor">{lang}wcf.user.edit{/lang}</a></li>{/if}
                                                                {/if}
index 9ddcdff1e83697d7ca048566a995d5b9f2400b93..670a49511d9be2cc544f3acd6171685072141a27 100644 (file)
                <p class="info" role="status">{lang}wcf.page.availableUpdates{/lang}</p>
        {/if}
        
-       {if $__wcf->user->activationCode && REGISTER_ACTIVATION_METHOD == 1 && $templateName != 'registerActivation' && $templateName != 'register' && $templateName != 'redirect' && $__wcf->user->getBlacklistMatches()|empty}
+       {* user needs email confirmation to be activated *}
+       {if !$__wcf->user->isEmailConfirmed() && !$__wcf->user->isActivated() && REGISTER_ACTIVATION_METHOD & 1 && $templateName != 'registerActivation' && $templateName != 'register' && $templateName != 'redirect' && $__wcf->user->getBlacklistMatches()|empty}
                <p class="warning" role="status">{lang}wcf.user.register.needActivation{/lang}</p>
        {/if}
        
+       {* user needs admin activation *}
+       {if $__wcf->user->isEmailConfirmed() && REGISTER_ACTIVATION_METHOD & 2 && !$__wcf->user->isActivated() && $templateName != 'registerActivation' && $templateName != 'register' && $templateName != 'redirect' && $__wcf->user->getBlacklistMatches()|empty}
+               <p class="warning" role="status">{lang}wcf.user.register.needAdminActivation{/lang}</p>
+       {/if}
+       
+       {* user needs email activation w/o beeing disabled *}
+       {if !$__wcf->user->isEmailConfirmed() && REGISTER_ACTIVATION_METHOD & 1 && $__wcf->user->isActivated() && $templateName != 'registerActivation' && $templateName != 'register' && $templateName != 'redirect' && $__wcf->user->getBlacklistMatches()|empty}
+               <p class="warning" role="status">{lang}wcf.user.register.needEmailConfirmation{/lang}</p>
+       {/if}
+       
        {hascontent}
                {content}
                        {foreach from=$__wcf->getNoticeHandler()->getVisibleNotices() item='notice'}
index 492d914b348b0e3f80f97082cd98ecef1bb99674..c96645c3d4f0afb93345317ba41b251fbcd5aafb 100644 (file)
@@ -31,7 +31,7 @@ class RegisterActivationForm extends AbstractForm {
        
        /**
         * activation code
-        * @var integer
+        * @var string
         */
        public $activationCode = '';
        
@@ -52,7 +52,7 @@ class RegisterActivationForm extends AbstractForm {
                        $this->user = new User($userID);
                        if ($this->user->userID) $this->username = $this->user->username;
                }
-               if (!empty($_GET['a'])) $this->activationCode = intval($_GET['a']);
+               if (!empty($_GET['a'])) $this->activationCode = StringUtil::trim($_GET['a']);
        }
        
        /**
@@ -65,7 +65,7 @@ class RegisterActivationForm extends AbstractForm {
                        $this->username = StringUtil::trim($_POST['username']);
                        $this->user = User::getUserByUsername($this->username);
                }
-               if (isset($_POST['activationCode'])) $this->activationCode = intval($_POST['activationCode']);
+               if (isset($_POST['activationCode'])) $this->activationCode = StringUtil::trim($_POST['activationCode']);
        }
        
        /**
@@ -79,13 +79,13 @@ class RegisterActivationForm extends AbstractForm {
                        throw new UserInputException('username', 'notFound');
                }
                
-               // user is already enabled
+               // user email is already confirmed
                if ($this->user->isEmailConfirmed()) {
                        throw new NamedUserException(WCF::getLanguage()->get('wcf.user.registerActivation.error.userAlreadyEnabled'));
                }
                
                // check given activation code
-               if (\hash_equals($this->activationCode, $this->user->emailConfirmed)) {
+               if (!\hash_equals($this->activationCode, $this->user->emailConfirmed)) {
                        throw new UserInputException('activationCode', 'invalid');
                }
                
@@ -106,7 +106,14 @@ class RegisterActivationForm extends AbstractForm {
                $this->saved();
                
                // forward to index page
-               HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.user.registerActivation.success'), 10);
+               if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_ADMIN && !$this->user->isActivated()) {
+                       $redirectText = WCF::getLanguage()->getDynamicVariable('wcf.user.registerActivation.success.awaitAdminActivation');
+               }
+               else {
+                       $redirectText = WCF::getLanguage()->getDynamicVariable('wcf.user.registerActivation.success');
+               }
+               
+               HeaderUtil::delayedRedirect(LinkHandler::getInstance()->getLink(), $redirectText, 10);
                exit;
        }
        
index 2b03fa48dfed6d40106907b98cd741b4013b3e83..3181f34f7910084981de498072e9a312657dc883 100644 (file)
@@ -4602,6 +4602,7 @@ sich{/if} nicht bei uns registriert {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}
                <item name="wcf.user.registerActivation"><![CDATA[Registrierung abschließen]]></item>
                <item name="wcf.user.registerActivation.error.userAlreadyEnabled"><![CDATA[Dieser Benutzer ist bereits freigeschaltet.]]></item>
                <item name="wcf.user.registerActivation.success"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Benutzerkonto wurde erfolgreich freigeschaltet.]]></item>
+               <item name="wcf.user.registerActivation.success.awaitAdminActivation"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} E-Mail-Adresse wurde erfolgreich freigeschaltet. {if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Benutzerkonto muss nun noch von einem Administrator freigeschaltet werden.]]></item>
                <item name="wcf.user.activationCode.error.invalid"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du hast{else}Sie haben{/if} einen ungültigen Aktivierungscode eingegeben. {if LANGUAGE_USE_INFORMAL_VARIANT}Klicke auf den unten stehenden Link, falls du einen neuen Aktivierungscode anfordern möchtest.{else}Klicken Sie auf den unten stehenden Link, falls Sie einen neuen Aktivierungscode anfordern möchten.{/if}]]></item>
                <item name="wcf.user.registerNewActivationCode.email.description"><![CDATA[Optional {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} hier eine neue E-Mail-Adresse eintragen, an die der neue Aktivierungscode gesendet werden soll. {if LANGUAGE_USE_INFORMAL_VARIANT}Lasse{else}Lassen Sie{/if} dieses Feld frei, wenn der Aktivierungscode an die bestehende Adresse geschickt werden soll.]]></item>
                <item name="wcf.user.newActivationCode.success"><![CDATA[Eine E-Mail mit dem neuen Aktivierungscode wurde an {$email} versendet.]]></item>
@@ -4733,6 +4734,8 @@ dich{else}wenden
 Sie sich{/if} bitte an den Administrator unter: {@MAIL_ADMIN_ADDRESS}. Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du
 dich{else}Sie
 sich{/if} nicht bei uns registriert {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}haben{/if}, dann {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} diese E-Mail ignorieren.]]></item>
+               <item name="wcf.user.register.needAdminActivation"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Benutzerkonto muss noch von einem Administrator freigeschaltet werden, um den vollen Funktionsumfang dieser Seite nutzen zu können.]]></item>
+               <item name="wcf.user.register.needEmailConfirmation"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} E-Mail-Adresse muss noch aktiviert werden. <a href="{link controller='RegisterActivation'}{/link}">Aktivieren Sie jetzt Ihre E-Mail-Adresse</a>]]></item>
                <!-- Success Messages -->
                <item name="wcf.user.register.success"><![CDATA[Vielen Dank für die Registrierung, {$user->username}. {if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} Registrierung ist hiermit vollständig abgeschlossen.]]></item>
                <item name="wcf.user.register.success.needActivation"><![CDATA[Vielen Dank für die Registrierung, {$user->username}.<br>
index 0707122a5178b57b8c4f8b7217eb4dff148d75c4..dd15d12dfb19a9795a8846c7da7fa0b140f14b31 100644 (file)
@@ -4598,6 +4598,7 @@ not register with us.]]></item>
                <item name="wcf.user.registerActivation"><![CDATA[Complete Registration]]></item>
                <item name="wcf.user.registerActivation.error.userAlreadyEnabled"><![CDATA[The user is already activated.]]></item>
                <item name="wcf.user.registerActivation.success"><![CDATA[The user account has been activated.]]></item>
+               <item name="wcf.user.registerActivation.success.awaitAdminActivation"><![CDATA[{The email address has been activated. Now your account must be activated by an administrator.]]></item>
                <item name="wcf.user.activationCode.error.invalid"><![CDATA[You have provided an invalid activation code. Click the link below if you wish to request a new activation code.]]></item>
                <item name="wcf.user.registerNewActivationCode.email.description"><![CDATA[You can provide a different email address or leave it empty to send the code to the same email address again.]]></item>
                <item name="wcf.user.newActivationCode.success"><![CDATA[The activation code has been sent to “{$email}”.]]></item>
@@ -4726,6 +4727,8 @@ Your activation code is: {@$mailbox->getUser()->activationCode} {* this line end
 If you have trouble confirming your email address, please contact the
 administrator at: {@MAIL_ADMIN_ADDRESS}. Please ignore this email if you did
 not register with us.]]></item>
+               <item name="wcf.user.register.needAdminActivation"><![CDATA[Your account must be activated by an administrator in order to use the full scope of the website.]]></item>
+               <item name="wcf.user.register.needEmailConfirmation"><![CDATA[Your email address is not activated yet. <a href="{link controller='RegisterActivation'}{/link}">Activate now your email address</a>.]]></item>
                <!-- Success Messages -->
                <item name="wcf.user.register.success"><![CDATA[Thank you for registering, {$user->username}.<br>
 Your registration is now completed.]]></item>