From a477e3522933a7204b02013cd6b6d47d0db1d254 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Fri, 22 May 2020 15:00:41 +0200 Subject: [PATCH] Add indicator of the activation status in the frontend --- .../templates/accountManagement.tpl | 2 +- .../templates/registerActivation.tpl | 4 ++-- com.woltlab.wcf/templates/user.tpl | 2 +- com.woltlab.wcf/templates/userNotice.tpl | 13 ++++++++++++- .../lib/form/RegisterActivationForm.class.php | 19 +++++++++++++------ wcfsetup/install/lang/de.xml | 3 +++ wcfsetup/install/lang/en.xml | 3 +++ 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/com.woltlab.wcf/templates/accountManagement.tpl b/com.woltlab.wcf/templates/accountManagement.tpl index cc35e9d75f..bf7285df53 100644 --- a/com.woltlab.wcf/templates/accountManagement.tpl +++ b/com.woltlab.wcf/templates/accountManagement.tpl @@ -137,7 +137,7 @@ {event name='changeEmailFields'} - {if REGISTER_ACTIVATION_METHOD == 1 && $__wcf->getUser()->reactivationCode != 0} + {if REGISTER_ACTIVATION_METHOD & 1 && $__wcf->getUser()->reactivationCode != 0}
diff --git a/com.woltlab.wcf/templates/registerActivation.tpl b/com.woltlab.wcf/templates/registerActivation.tpl index 2711ff0a9e..b7c87f54e2 100644 --- a/com.woltlab.wcf/templates/registerActivation.tpl +++ b/com.woltlab.wcf/templates/registerActivation.tpl @@ -1,6 +1,6 @@ {include file='header' __disableAds=true} -{if $__wcf->user->userID && $__wcf->user->activationCode}

{lang}wcf.user.registerActivation.info{/lang}

{/if} +{if $__wcf->user->userID && !$__wcf->user->isEmailConfirmed()}

{lang}wcf.user.registerActivation.info{/lang}

{/if} {include file='formError'} @@ -21,7 +21,7 @@
- + {if $errorField == 'activationCode'} {if $errorType == 'invalid'}{lang}wcf.user.activationCode.error.invalid{/lang}{/if} diff --git a/com.woltlab.wcf/templates/user.tpl b/com.woltlab.wcf/templates/user.tpl index b69b4fad72..73783be656 100644 --- a/com.woltlab.wcf/templates/user.tpl +++ b/com.woltlab.wcf/templates/user.tpl @@ -307,7 +307,7 @@ {if $__wcf->session->getPermission('admin.user.canDisableAvatar')}
  • {lang}wcf.user.{if $user->disableAvatar}enable{else}disable{/if}Avatar{/lang}
  • {/if} {if $__wcf->session->getPermission('admin.user.canDisableSignature')}
  • {lang}wcf.user.{if $user->disableSignature}enable{else}disable{/if}Signature{/lang}
  • {/if} {if MODULE_USER_COVER_PHOTO && $__wcf->session->getPermission('admin.user.canDisableCoverPhoto')}
  • {lang}wcf.user.{if $user->disableCoverPhoto}enable{else}disable{/if}CoverPhoto{/lang}
  • {/if} - {if $__wcf->session->getPermission('admin.user.canEnableUser')}
  • {lang}wcf.acp.user.{if $user->activationCode}enable{else}disable{/if}{/lang}
  • {/if} + {if $__wcf->session->getPermission('admin.user.canEnableUser')}
  • {lang}wcf.acp.user.{if $user->isActivated())}enable{else}disable{/if}{/lang}
  • {/if} {if $__wcf->session->getPermission('admin.general.canUseAcp') && $__wcf->session->getPermission('admin.user.canEditUser')}
  • {lang}wcf.user.edit{/lang}
  • {/if} {/if} diff --git a/com.woltlab.wcf/templates/userNotice.tpl b/com.woltlab.wcf/templates/userNotice.tpl index 9ddcdff1e8..670a49511d 100644 --- a/com.woltlab.wcf/templates/userNotice.tpl +++ b/com.woltlab.wcf/templates/userNotice.tpl @@ -10,10 +10,21 @@

    {lang}wcf.page.availableUpdates{/lang}

    {/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}

    {lang}wcf.user.register.needActivation{/lang}

    {/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} +

    {lang}wcf.user.register.needAdminActivation{/lang}

    + {/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} +

    {lang}wcf.user.register.needEmailConfirmation{/lang}

    + {/if} + {hascontent} {content} {foreach from=$__wcf->getNoticeHandler()->getVisibleNotices() item='notice'} diff --git a/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php b/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php index 492d914b34..c96645c3d4 100644 --- a/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php +++ b/wcfsetup/install/files/lib/form/RegisterActivationForm.class.php @@ -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; } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 2b03fa48df..3181f34f79 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -4602,6 +4602,7 @@ sich{/if} nicht bei uns registriert {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else} + @@ -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.]]> + + Aktivieren Sie jetzt Ihre E-Mail-Adresse]]> username}. {if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} Registrierung ist hiermit vollständig abgeschlossen.]]> username}.
    diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 0707122a51..dd15d12dfb 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -4598,6 +4598,7 @@ not register with us.]]>
    + @@ -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.]]> + + Activate now your email address.]]> username}.
    Your registration is now completed.]]>
    -- 2.20.1