From: Tim Düsterhus Date: Sat, 30 Jul 2016 12:11:51 +0000 (+0200) Subject: Convert new email activation to new email API X-Git-Tag: 3.0.0_Beta_1~887 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4f85fd6c32fa2cd6ccb5302c11f55210cb85dc10;p=GitHub%2FWoltLab%2FWCF.git Convert new email activation to new email API --- diff --git a/com.woltlab.wcf/templates/accountManagement.tpl b/com.woltlab.wcf/templates/accountManagement.tpl index f44370aea9..84d895b331 100644 --- a/com.woltlab.wcf/templates/accountManagement.tpl +++ b/com.woltlab.wcf/templates/accountManagement.tpl @@ -141,7 +141,7 @@
- {lang newEmail=$__wcf->user->email}wcf.user.changeEmail.needReactivation{/lang} + {lang newEmail=$__wcf->user->newEmail}wcf.user.changeEmail.needReactivation{/lang} {lang}wcf.user.emailActivation{/lang}
diff --git a/com.woltlab.wcf/templates/email_changeEmailNeedReactivation.tpl b/com.woltlab.wcf/templates/email_changeEmailNeedReactivation.tpl new file mode 100644 index 0000000000..069f5c642e --- /dev/null +++ b/com.woltlab.wcf/templates/email_changeEmailNeedReactivation.tpl @@ -0,0 +1,19 @@ +{if $mimeType === 'text/plain'} +{capture assign='content'}{lang}wcf.user.changeEmail.needReactivation.mail.plaintext{/lang}{/capture} +{include file='email_plaintext'} +{else} + {capture assign='content'} +

{lang}wcf.user.changeEmail.needReactivation.mail.html.headline{/lang}

+ {lang}wcf.user.changeEmail.needReactivation.mail.html.intro{/lang} + + {capture assign=button} + + {lang}wcf.user.changeEmail.needReactivation.mail.html.activate{/lang} + + {/capture} + {include file='email_paddingHelper' class='button' content=$button sandbox=true} + + {lang}wcf.user.changeEmail.needReactivation.mail.html.outro{/lang} + {/capture} + {include file='email_html'} +{/if} diff --git a/wcfsetup/install/files/lib/form/AccountManagementForm.class.php b/wcfsetup/install/files/lib/form/AccountManagementForm.class.php index d8ba03e3c6..2c70a20548 100644 --- a/wcfsetup/install/files/lib/form/AccountManagementForm.class.php +++ b/wcfsetup/install/files/lib/form/AccountManagementForm.class.php @@ -2,8 +2,12 @@ namespace wcf\form; use wcf\data\user\User; use wcf\data\user\UserAction; +use wcf\data\user\UserList; use wcf\system\exception\UserInputException; -use wcf\system\mail\Mail; +use wcf\system\email\mime\MimePartFacade; +use wcf\system\email\mime\RecipientAwareTextMimePart; +use wcf\system\email\Email; +use wcf\system\email\UserMailbox; use wcf\system\menu\user\UserMenu; use wcf\system\WCF; use wcf\util\HeaderUtil; @@ -223,7 +227,7 @@ class AccountManagementForm extends AbstractForm { // email if (WCF::getSession()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) { - if (empty($this->email)) { + if (empty($this->email)) { throw new UserInputException('email'); } @@ -346,14 +350,6 @@ class AccountManagementForm extends AbstractForm { $updateParameters['reactivationCode'] = $activationCode; $updateParameters['newEmail'] = $this->email; - $messageData = [ - 'username' => WCF::getUser()->username, - 'userID' => WCF::getUser()->userID, - 'activationCode' => $activationCode - ]; - - $mail = new Mail([WCF::getUser()->username => $this->email], WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject'), WCF::getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail', $messageData)); - $mail->send(); $success[] = 'wcf.user.changeEmail.needReactivation'; } } @@ -440,6 +436,25 @@ class AccountManagementForm extends AbstractForm { HeaderUtil::setCookie('password', PasswordUtil::getSaltedHash($updateParameters['password'], $user->password), TIME_NOW + 365 * 24 * 3600); } + if (isset($updateParameters['newEmail']) && isset($updateParameters['reactivationCode'])) { + // Use user list to allow overriding of the fields without duplicating logic + $userList = new UserList(); + $userList->useQualifiedShorthand = false; + $userList->sqlSelects .= ", user_table.*, newEmail AS email"; + $userList->getConditionBuilder()->add('user_table.userID = ?', [WCF::getUser()->userID]); + $userList->readObjects(); + $user = $userList->getObjects()[WCF::getUser()->userID]; + + $email = new Email(); + $email->addRecipient(new UserMailbox($user)); + $email->setSubject($user->getLanguage()->getDynamicVariable('wcf.user.changeEmail.needReactivation.mail.subject')); + $email->setBody(new MimePartFacade([ + new RecipientAwareTextMimePart('text/html', 'email_changeEmailNeedReactivation'), + new RecipientAwareTextMimePart('text/plain', 'email_changeEmailNeedReactivation') + ])); + $email->send(); + } + $this->saved(); $success = array_merge($success, WCF::getTPL()->get('success') ?: []); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 9dc3b5e3c5..320c13d548 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -2912,25 +2912,29 @@ dann wird diese Anfrage am {$mailbox->getUser()->lastLostPasswordRequestTime+864 - + getUser()->username},]]> + {if LANGUAGE_USE_INFORMAL_VARIANT}du hast deine{else}Sie haben Ihre{/if} E-Mail-Adresse auf der Website: {PAGE_TITLE|language} geändert. +Zum Abschließen dieser Änderung {if LANGUAGE_USE_INFORMAL_VARIANT}musst du{else}müssen Sie{/if} einmalig die Gültigkeit der neuen E-Mail-Adresse bestätigen:

]]>
+ + {if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Aktivierungscode lautet: {$mailbox->getUser()->reactivationCode}.

+

{if LANGUAGE_USE_INFORMAL_VARIANT}Wenn du Probleme mit der Aktivierung haben solltest, wende dich{else}Wenn Sie Probleme mit der Aktivierung haben, wenden Sie sich{/if} bitte an den Administrator: +{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.

]]>
+ getUser()->username}, -**** Funktioniert der Link oben nicht? **** -Wenn der Link nicht funktioniert, {if LANGUAGE_USE_INFORMAL_VARIANT}solltest du{else}sollten Sie{/if} folgende Adresse in {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Browser aufrufen: -{link controller='EmailActivation' isEmail=true}{/link} +{if LANGUAGE_USE_INFORMAL_VARIANT}du hast deine{else}Sie haben Ihre{/if} E-Mail-Adresse auf der Website: {@PAGE_TITLE|language} [URL:{link isEmail=true}{/link}] geändert. +Zum Abschließen dieser Änderung {if LANGUAGE_USE_INFORMAL_VARIANT}musst du{else}müssen Sie{/if} einmalig die Gültigkeit der neuen E-Mail-Adresse bestätigen: -Bitte {if LANGUAGE_USE_INFORMAL_VARIANT}achte{else}achten Sie{/if} darauf, dass keine Leerzeichen in der Adresse sind. -{if LANGUAGE_USE_INFORMAL_VARIANT}Wenn du den Link aufgerufen hast, musst du{else}Wenn Sie den Link aufgerufen haben, müssen Sie{/if} auf der erscheinenden Seite {if LANGUAGE_USE_INFORMAL_VARIANT}deine{else}Ihre{/if} Benutzernummer sowie den Aktivierungscode eingeben. + {link controller='EmailActivation' isEmail=true}u={@$mailbox->getUser()->userID}&a={@$mailbox->getUser()->reactivationCode}{/link} {* this line ends with a space *} -{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} Benutzernummer lautet: {@$userID} -{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Aktivierungscode lautet: {@$activationCode} +{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Aktivierungscode lautet: {@$mailbox->getUser()->reactivationCode} {* this line ends with a space *} -{if LANGUAGE_USE_INFORMAL_VARIANT}Wenn du Probleme mit der Aktivierung haben solltest, wende dich{else}Wenn Sie Probleme mit der Aktivierung haben, wenden Sie sich{/if} bitte an den Administrator: {@MAIL_ADMIN_ADDRESS} ]]> - +{if LANGUAGE_USE_INFORMAL_VARIANT}Wenn du Probleme mit der Aktivierung haben solltest, wende dich{else}Wenn Sie Probleme mit der Aktivierung haben, wenden Sie sich{/if} bitte an den Administrator: {@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.]]> @@ -3034,7 +3038,7 @@ Bitte {if LANGUAGE_USE_INFORMAL_VARIANT}achte{else}achten Sie{/if} darauf, dass vielen Dank für {if LANGUAGE_USE_INFORMAL_VARIANT}deine{else}Ihre{/if} Registrierung auf der Website: {PAGE_TITLE|language}. Bevor {if LANGUAGE_USE_INFORMAL_VARIANT}du dein{else}Sie Ihr{/if} Benutzerkonto vollständig verwenden können ist es notwendig, dass {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} einmalig die Gültigkeit {if LANGUAGE_USE_INFORMAL_VARIANT}deiner{else}Ihrer{/if} E-Mail-Adresse {if LANGUAGE_USE_INFORMAL_VARIANT}bestätigst{else}bestätigen{/if}:

]]>
- + {if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Aktivierungscode lautet: {$mailbox->getUser()->activationCode}.

Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} Probleme mit der Aktivierung {if LANGUAGE_USE_INFORMAL_VARIANT}deines{else}Ihres{/if} Benutzerkontos {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}haben{/if}, dann {if LANGUAGE_USE_INFORMAL_VARIANT}wende dich{else}wenden Sie sich{/if} bitte an den Administrator diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 80ac2a37bf..8ad41771ff 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2939,23 +2939,29 @@ the website {@PAGE_TITLE|language}.

- + getUser()->username},]]> + you’ve changed your email address on: {PAGE_TITLE|language}. To complete +this change it is required to confirm your new email address once:

]]>
+ + Your activation code is: {$mailbox->getUser()->reactivationCode}.

+

If you have troubles confirming your email address, please contact the administrator at: +{MAIL_ADMIN_ADDRESS}. Please ignore this email if +you did not register an account with us.

]]>
+ getUser()->username}, -**** Unable to click or open the link above? **** -Please open the link below in your browser: -{link controller='EmailActivation' isEmail=true}{/link} +you’ve changed your email address on: {@PAGE_TITLE|language} [URL:{link isEmail=true}{/link}]. To complete +this change it is required to confirm your new email address once: -Once prompted please provide the following details: + {link controller='EmailActivation' isEmail=true}u={@$mailbox->getUser()->userID}&a={@$mailbox->getUser()->reactivationCode}{/link} {* this line ends with a space *} -You User ID: {@$userID} -Activation Code: {@$activationCode} +Your activation code is: {@$mailbox->getUser()->reactivationCode} {* this line ends with a space *} -If you cannot activate your email address or have any troubles following the instructions, please contact the administrator: {@MAIL_ADMIN_ADDRESS}]]> - +If you have troubles confirming your email address, please contect the +administrator at: {@MAIL_ADMIN_ADDRESS}. Please ignore this email if you did +not register with us.]]>
@@ -3059,7 +3065,7 @@ If you cannot activate your email address or have any troubles following the ins thank you for registering at: {PAGE_TITLE|language}. Before you are able to use your user account to it’s full extent it is required that you confirm validity of your email address once:

]]>
- + Your activation code is: {$mailbox->getUser()->activationCode}.

If you have troubles confirming your email address, please contact the administrator at: