Convert new email activation to new email API
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 30 Jul 2016 12:11:51 +0000 (14:11 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 30 Jul 2016 12:12:15 +0000 (14:12 +0200)
com.woltlab.wcf/templates/accountManagement.tpl
com.woltlab.wcf/templates/email_changeEmailNeedReactivation.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/form/AccountManagementForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index f44370aea943c3639dd0133c04b853d5450aa507..84d895b3313e4ec824739954c9e80c0abcf80b17 100644 (file)
                                <dl>
                                        <dt></dt>
                                        <dd>
-                                               <small>{lang newEmail=$__wcf->user->email}wcf.user.changeEmail.needReactivation{/lang}</small>
+                                               <small>{lang newEmail=$__wcf->user->newEmail}wcf.user.changeEmail.needReactivation{/lang}</small>
                                                <small><a href="{link controller='EmailActivation'}{/link}"><span>{lang}wcf.user.emailActivation{/lang}</span></a></small>
                                        </dd>
                                </dl>
diff --git a/com.woltlab.wcf/templates/email_changeEmailNeedReactivation.tpl b/com.woltlab.wcf/templates/email_changeEmailNeedReactivation.tpl
new file mode 100644 (file)
index 0000000..069f5c6
--- /dev/null
@@ -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'}
+       <h1>{lang}wcf.user.changeEmail.needReactivation.mail.html.headline{/lang}</h1>
+       {lang}wcf.user.changeEmail.needReactivation.mail.html.intro{/lang}
+
+       {capture assign=button}
+       <a href="{link controller='EmailActivation' isEmail=true}u={@$mailbox->getUser()->userID}&a={@$mailbox->getUser()->reactivationCode}{/link}">
+               {lang}wcf.user.changeEmail.needReactivation.mail.html.activate{/lang}
+       </a>
+       {/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}
index d8ba03e3c6e6abdc83569aba3aa486469d40e3f5..2c70a2054812419a97578a73e9e4c3079a41fd7d 100644 (file)
@@ -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') ?: []);
index 9dc3b5e3c59d74f8ded99249723e17488608f5e5..320c13d548491f2e7a3fa78324803e4dc58df051 100644 (file)
@@ -2912,25 +2912,29 @@ dann wird diese Anfrage am {$mailbox->getUser()->lastLostPasswordRequestTime+864
                <item name="wcf.user.changeUsername.success"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Benutzername wurde erfolgreich geändert.]]></item>
                <item name="wcf.user.changeEmail.success"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} E-Mail-Adresse wurde erfolgreich geändert.]]></item>
                <item name="wcf.user.changeEmail.needReactivation"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Deine{else}Ihre{/if} neue E-Mail-Adresse{if $newEmail|isset} („{$newEmail}“){/if} muss noch aktiviert werden. Dazu wurde eine E-Mail mit einem Aktivierungslink an die neue Adresse gesandt. {if LANGUAGE_USE_INFORMAL_VARIANT}Du musst{else}Sie müssen{/if} diesen Aktivierungslink aufrufen, um die neue E-Mail-Adresse zu aktivieren.]]></item>
-               <item name="wcf.user.changeEmail.needReactivation.mail"><![CDATA[Hallo {@$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}Bitte bestätige die Gültigkeit deiner neuen E-Mail-Adresse, indem du folgenden Link aufrufst{else}Bitte bestätigen Sie die Gültigkeit Ihrer neuen E-Mail-Adresse, indem Sie folgenden Link aufrufen{/if}:
-{link controller='EmailActivation' isEmail=true}u={@$userID}&a={@$activationCode}{/link} 
+               <item name="wcf.user.changeEmail.needReactivation.mail.subject"><![CDATA[Aktivierung der neuen E-Mail-Adresse auf der Website: {@PAGE_TITLE|language}]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.headline"><![CDATA[Hallo {$mailbox->getUser()->username},]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.intro"><![CDATA[
+<p>{if LANGUAGE_USE_INFORMAL_VARIANT}du hast deine{else}Sie haben Ihre{/if} E-Mail-Adresse auf der Website: <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}</a> 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:</p>]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.activate"><![CDATA[Neue E-Mail-Adresse aktivieren]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.outro"><![CDATA[
+<p>{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Aktivierungscode lautet: <code>{$mailbox->getUser()->reactivationCode}</code>.</p>
+<p>{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:
+<a href="mailto:{MAIL_ADMIN_ADDRESS}">{MAIL_ADMIN_ADDRESS}</a>. 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.</p>]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.plaintext"><![CDATA[Hallo {$mailbox->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} ]]></item>
-               <item name="wcf.user.changeEmail.needReactivation.mail.subject"><![CDATA[Aktivierung der neuen E-Mail-Adresse auf der Website: {@PAGE_TITLE|language}]]></item>
+{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.]]></item>
                <item name="wcf.user.changePassword.success"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Kennwort wurde erfolgreich geändert.]]></item>
                <item name="wcf.user.activationCode"><![CDATA[9-stelliger Aktivierungscode]]></item>
                <item name="wcf.user.newActivationCode"><![CDATA[Neuen Aktivierungscode anfordern]]></item>
@@ -3034,7 +3038,7 @@ Bitte {if LANGUAGE_USE_INFORMAL_VARIANT}achte{else}achten Sie{/if} darauf, dass
                <item name="wcf.user.register.needActivation.mail.html.intro"><![CDATA[
 <p>vielen Dank für {if LANGUAGE_USE_INFORMAL_VARIANT}deine{else}Ihre{/if} Registrierung auf der Website: <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}</a>. 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}:</p>]]></item>
-               <item name="wcf.user.register.needActivation.mail.html.activate"><![CDATA[Benutzerkonto aktivieren!]]></item>
+               <item name="wcf.user.register.needActivation.mail.html.activate"><![CDATA[Benutzerkonto aktivieren]]></item>
                <item name="wcf.user.register.needActivation.mail.html.outro"><![CDATA[
 <p>{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Aktivierungscode lautet: <code>{$mailbox->getUser()->activationCode}</code>.</p>
 <p>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
index 80ac2a37bf65ff54d794752454b5060e640b2729..8ad41771ff1a659909fffa82f786f7eed119775a 100644 (file)
@@ -2939,23 +2939,29 @@ the website <a href="{link isEmail=true}{/link}">{@PAGE_TITLE|language}</a>.</p>
                <item name="wcf.user.changeUsername.success"><![CDATA[Username was changed.]]></item>
                <item name="wcf.user.changeEmail.success"><![CDATA[Email Address was changed.]]></item>
                <item name="wcf.user.changeEmail.needReactivation"><![CDATA[Your new email address{if $newEmail|isset} (“{$newEmail}”){/if} must be verified first. You should have received an email sent to your new email address containing an activation link. Open the link to verify your new email address.]]></item>
-               <item name="wcf.user.changeEmail.needReactivation.mail"><![CDATA[Dear {@$username},
-
-you’ve changed your email address on: {@PAGE_TITLE|language}. It is required to open the link below in order to verify this email address.
-
-{link controller='EmailActivation' isEmail=true}u={@$userID}&a={@$activationCode}{/link} 
+               <item name="wcf.user.changeEmail.needReactivation.mail.subject"><![CDATA[Email Activation for Website: {@PAGE_TITLE|language}]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.headline"><![CDATA[Dear {$mailbox->getUser()->username},]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.intro"><![CDATA[
+<p>you’ve changed your email address on: <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}</a>. To complete
+this change it is required to confirm your new email address once:</p>]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.activate"><![CDATA[Confirm my email address]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.html.outro"><![CDATA[
+<p>Your activation code is: <code>{$mailbox->getUser()->reactivationCode}</code>.</p>
+<p>If you have troubles confirming your email address, please contact the administrator at:
+<a href="mailto:{MAIL_ADMIN_ADDRESS}">{MAIL_ADMIN_ADDRESS}</a>. Please ignore this email if
+you did not register an account with us.</p>]]></item>
+               <item name="wcf.user.changeEmail.needReactivation.mail.plaintext"><![CDATA[Dear {$mailbox->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}]]></item>
-               <item name="wcf.user.changeEmail.needReactivation.mail.subject"><![CDATA[Email Activation for Website: {@PAGE_TITLE|language}]]></item>
+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.]]></item>
                <item name="wcf.user.changePassword.success"><![CDATA[Password has been changed.]]></item>
                <item name="wcf.user.activationCode"><![CDATA[9-digit Activation Code]]></item>
                <item name="wcf.user.newActivationCode"><![CDATA[Request New Activation Code]]></item>
@@ -3059,7 +3065,7 @@ If you cannot activate your email address or have any troubles following the ins
                <item name="wcf.user.register.needActivation.mail.html.intro"><![CDATA[
 <p>thank you for registering at: <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}</a>. 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:</p>]]></item>
-               <item name="wcf.user.register.needActivation.mail.html.activate"><![CDATA[Confirm my email address!]]></item>
+               <item name="wcf.user.register.needActivation.mail.html.activate"><![CDATA[Confirm my email address]]></item>
                <item name="wcf.user.register.needActivation.mail.html.outro"><![CDATA[
 <p>Your activation code is: <code>{$mailbox->getUser()->activationCode}</code>.</p>
 <p>If you have troubles confirming your email address, please contact the administrator at: