Use new email API for activation notifications
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 6 Jun 2016 22:11:51 +0000 (00:11 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 29 Jul 2016 14:24:17 +0000 (16:24 +0200)
com.woltlab.wcf/templates/email_adminActivation.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

diff --git a/com.woltlab.wcf/templates/email_adminActivation.tpl b/com.woltlab.wcf/templates/email_adminActivation.tpl
new file mode 100644 (file)
index 0000000..0c649ac
--- /dev/null
@@ -0,0 +1,11 @@
+{if $mimeType === 'text/plain'}
+{capture assign='content'}{lang}wcf.acp.user.activation.mail.plaintext{/lang}{/capture}
+{include file='email_plaintext'}
+{else}
+       {capture assign='content'}
+       <h1>{lang}wcf.acp.user.activation.mail.html.headline{/lang}</h1>
+       {lang}wcf.acp.user.activation.mail.html.text{/lang}
+       {/capture}
+       
+       {include file='email_html'}
+{/if}
index c5b296ca3d1231f7ed8c694329e93e16b1d39f8e..f700923578df0ecca6627f010b0405d8b03e5938 100644 (file)
@@ -11,7 +11,10 @@ use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\PermissionDeniedException;
 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\request\RequestHandler;
 use wcf\system\WCF;
 use wcf\util\UserRegistrationUtil;
@@ -585,10 +588,14 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                // send e-mail notification
                if (empty($this->parameters['skipNotification'])) {
                        foreach ($this->getObjects() as $user) {
-                               $mail = new Mail([$user->username => $user->email], $user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail.subject'), $user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail', [
-                                       'username' => $user->username
+                               $email = new Email();
+                               $email->addRecipient(new UserMailbox($user->getDecoratedObject()));
+                               $email->setSubject($user->getLanguage()->getDynamicVariable('wcf.acp.user.activation.mail.subject'));
+                               $email->setBody(new MimePartFacade([
+                                       new RecipientAwareTextMimePart('text/html', 'email_adminActivation'),
+                                       new RecipientAwareTextMimePart('text/plain', 'email_adminActivation')
                                ]));
-                               $mail->send();
+                               $email->send();
                        }
                }
                
index efe27d3828565e0cf2b4a1840f002c5e2087c8cd..e7d0ccea51492b9bdd4d29eca72df50f6b73c27f 100644 (file)
@@ -1799,11 +1799,18 @@ Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} unter <em>System -&gt; O
                <item name="wcf.acp.user.authentication.failure.environment.user"><![CDATA[Benutzer]]></item>
                <item name="wcf.acp.user.authentication.failure.environment.admin"><![CDATA[Administration]]></item>
                <item name="wcf.acp.user.authentication.failure.time"><![CDATA[Datum]]></item>
-               <item name="wcf.acp.user.activation.mail"><![CDATA[Hallo {@$username},
-
-{if LANGUAGE_USE_INFORMAL_VARIANT}dein{else}Ihr{/if} Benutzerkonto auf der Website: {@PAGE_TITLE|language} wurde vom Administrator freigeschaltet.
-{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} jetzt den vollen Funktionsumfang der Seite nutzen.]]></item>
                <item name="wcf.acp.user.activation.mail.subject"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Benutzerkonto auf der Website: {@PAGE_TITLE|language} wurde freigeschaltet]]></item>
+               <item name="wcf.acp.user.activation.mail.html.headline"><![CDATA[Hallo {$mailbox->getUser()->username},]]></item>
+               <item name="wcf.acp.user.activation.mail.html.text"><![CDATA[
+<p>{if LANGUAGE_USE_INFORMAL_VARIANT}Dein{else}Ihr{/if} Benutzerkonto auf der Website: <a href="{link}{/link}">{PAGE_TITLE|language}</a> wurde von einem Administrator
+freigeschaltet. {if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} die Funktionen {if LANGUAGE_USE_INFORMAL_VARIANT}deines{else}Ihres{/if} Benutzerkontos nun in vollem Umfang nutzen.</p>]]></item>
+               <item name="wcf.acp.user.activation.mail.plaintext"><![CDATA[Hallo {@$mailbox->getUser()->username},
+
+{if LANGUAGE_USE_INFORMAL_VARIANT}Ihr{else}Dein{/if} Benutzerkonto auf der Website: {@PAGE_TITLE|language} [1] wurde von
+einem Administrator freigeschaltet. {if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} die Funktionen {if LANGUAGE_USE_INFORMAL_VARIANT}deines{else}Ihres{/if}
+Benutzerkontos nun in vollem Umfang nutzen.
+
+[1] {link}{/link}]]></item>
                <item name="wcf.acp.user.notificationPresetSettings"><![CDATA[Vorgabewerte für Benachrichtigungen bearbeiten]]></item>
                <item name="wcf.acp.user.notificationPresetSettings.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Du kannst{else}Sie können{/if} auf dieser Seite die Standardeinstellungen für neue Benutzer festlegen, dies wirkt sich nicht auf bestehende Benutzer aus. Benutzer können abweichende Einstellungen festlegen.]]></item>
                <item name="wcf.acp.user.notificationPresetSettings.applyChangesToExistingUsers"><![CDATA[Änderungen auch auf bestehende Benutzerkonten anwenden]]></item>
@@ -3031,13 +3038,13 @@ Bitte {if LANGUAGE_USE_INFORMAL_VARIANT}achte{else}achten Sie{/if} darauf, dass
                <item name="wcf.user.register.needActivation.mail.subject"><![CDATA[Aktivierung der Registrierung auf der Website: {@PAGE_TITLE|language}]]></item>
                <item name="wcf.user.register.needActivation.mail.html.headline"><![CDATA[Hallo {$mailbox->getUser()->username},]]></item>
                <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}{/link}">{@PAGE_TITLE|language}</a>. Bevor {if LANGUAGE_USE_INFORMAL_VARIANT}du dein{else}Sie Ihr{/if}
-Benutzerkonto vollständig verwenden {if LANGUAGE_USE_INFORMAL_VARIANT}kannst{else}können{/if} ist es notwendig, dass {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} einmalig die Gültigkeit Ihrer E-Mail-Adresse {if LANGUAGE_USE_INFORMAL_VARIANT}bestätigst{else}bestätigen{/if}:</p>]]></item>
+<p>vielen Dank für {if LANGUAGE_USE_INFORMAL_VARIANT}deine{else}Ihre{/if} Registrierung auf der Website: <a href="{link}{/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.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 Ihres 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
-unter: <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},
+<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
+unter: <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.register.needActivation.mail.plaintext"><![CDATA[Hallo {$mailbox->getUser()->username},
 
@@ -3054,7 +3061,7 @@ Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} Probleme mit der Aktivie
 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 haben, dann {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} diese E-Mail ignorieren.
+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.
 
 [1] {link}{/link}]]></item>
                
index bbe194aea3a882a6adf38ca6a5b5368791246941..dbbd6aa3e0cbd4652a7d871c72455928f8ea99fb 100644 (file)
@@ -1772,11 +1772,18 @@ Login with your new password: {link controller='Login' isEmail=true}{/link}]]></
                <item name="wcf.acp.user.authentication.failure.environment.user"><![CDATA[User]]></item>
                <item name="wcf.acp.user.authentication.failure.environment.admin"><![CDATA[Administration]]></item>
                <item name="wcf.acp.user.authentication.failure.time"><![CDATA[Date]]></item>
-               <item name="wcf.acp.user.activation.mail"><![CDATA[Dear {@$username},
-
-your account on the website: {@PAGE_TITLE|language} has been approved by an administrator.
-You can now fully access the website.]]></item>
                <item name="wcf.acp.user.activation.mail.subject"><![CDATA[Your account on the website: {@PAGE_TITLE|language} has been approved]]></item>
+               <item name="wcf.acp.user.activation.mail.html.headline"><![CDATA[Dear {$mailbox->getUser()->username},]]></item>
+               <item name="wcf.acp.user.activation.mail.html.text"><![CDATA[
+<p>your account on the website: <a href="{link}{/link}">{PAGE_TITLE|language}</a> has been approved
+by an administrator. You are now able to use your user account to it’s full extend.</p>]]></item>
+               <item name="wcf.acp.user.activation.mail.plaintext"><![CDATA[Dear {@$mailbox->getUser()->username},
+
+your account on the website: {@PAGE_TITLE|language} [1] has been approved
+by an administrator. You are now able to use your user account to it’s
+full extend.
+
+[1] {link}{/link}]]></item>
                <item name="wcf.acp.user.notificationPresetSettings"><![CDATA[Default Notification Settings]]></item>
                <item name="wcf.acp.user.notificationPresetSettings.description"><![CDATA[You can set the default notification settings for new users, any changes made here do not affect existing users. Users may customize their settings at any time.]]></item>
                <item name="wcf.acp.user.notificationPresetSettings.applyChangesToExistingUsers"><![CDATA[Apply changes for existing users too]]></item>
@@ -3069,13 +3076,13 @@ If you cannot activate your email address or have any troubles following the ins
                <item name="wcf.user.register.needActivation.mail.subject"><![CDATA[Activate Your Registration for Website: {@PAGE_TITLE|language}]]></item>
                <item name="wcf.user.register.needActivation.mail.html.headline"><![CDATA[Dear {$mailbox->getUser()->username},]]></item>
                <item name="wcf.user.register.needActivation.mail.html.intro"><![CDATA[
-<p>thank you for registering at: <a href="{link}{/link}">{@PAGE_TITLE|language}</a>. Before you are able to use your
+<p>thank you for registering at: <a href="{link}{/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.outro"><![CDATA[
-<p>Your activation code is: <code>{@$mailbox->getUser()->activationCode}</code>.</p>
+<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:
-<a href="mailto:{@MAIL_ADMIN_ADDRESS}">{@MAIL_ADMIN_ADDRESS}</a>. Please ignore this email if
+<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.register.needActivation.mail.plaintext"><![CDATA[Dear {$mailbox->getUser()->username},