2 namespace wcf\system\user\notification\type;
3 use wcf\data\user\notification\recipient\UserNotificationRecipient;
4 use wcf\data\user\notification\UserNotification;
5 use wcf\data\user\UserEditor;
6 use wcf\system\mail\Mail;
7 use wcf\system\user\notification\event\IUserNotificationEvent;
9 use wcf\util\StringUtil;
12 * A notification type for sending mail notifications.
14 * @author Marcel Werk, Oliver Kliebisch
15 * @copyright 2001-2011 WoltLab GmbH, Oliver Kliebisch
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package com.woltlab.wcf.notification
18 * @subpackage system.user.notification.type
19 * @category Community Framework
21 class MailUserNotificationType extends AbstractUserNotificationType {
23 * @see wcf\system\user\notification\type\IUserNotificationType::send()
25 public function send(UserNotification $notification, UserNotificationRecipient $user, IUserNotificationEvent $event) {
27 $message = $event->getMessage($this, array(
29 'pageURL' => FileUtil::addTrailingSlash(PAGE_URL)
32 // append notification mail footer
33 $token = $user->notificationMailToken;
35 // generate token if not present
36 $token = StringUtil::substring($token = StringUtil::getHash(serialize(array($user->userID, StringUtil::getRandomID()))), 0, 20);
37 $editor = new UserEditor($user->getDecoratedObject());
38 $editor->updateUserOptions(array('notificationMailToken' => $token));
40 $message .= "\n".$user->getLanguage()->getDynamicVariable('wcf.user.notification.type.mail.footer', array(
42 'pageURL' => FileUtil::addTrailingSlash(PAGE_URL),
44 'notification' => $notification
47 // use short output as mail subject and strip its HTML
48 $shortMessage = StringUtil::stripHTML($notification->shortOutput);
51 $mail = new Mail(array($user->username => $user->email), $user->getLanguage()->getDynamicVariable('wcf.user.notification.type.mail.subject', array('title' => $shortMessage)), $message);
56 * @see wcf\system\user\notification\type\IUserNotificationType::revoke()
58 public function revoke(UserNotification $notification, UserNotificationRecipient $user, IUserNotificationEvent $event) {