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