2 namespace wcf\system\user\notification\event;
3 use wcf\data\comment\Comment;
4 use wcf\data\user\User;
5 use wcf\system\comment\CommentDataHandler;
6 use wcf\system\request\LinkHandler;
10 * User notification event for profile's owner for commment responses.
12 * @author Alexander Ebert
13 * @copyright 2001-2014 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package com.woltlab.wcf
16 * @subpackage system.user.notification.event
17 * @category Community Framework
19 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
21 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
23 protected $stackable = true;
26 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
28 protected function prepare() {
29 CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
30 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
34 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
36 public function getTitle() {
37 $count = count($this->getAuthors());
39 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array(
41 'timesTriggered' => $this->timesTriggered
45 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
49 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
51 public function getMessage() {
52 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
53 if ($comment->userID) {
54 $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID);
57 $commentAuthor = new User(null, array(
58 'username' => $comment->username
62 $authors = array_values($this->getAuthors());
63 $count = count($authors);
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array(
66 'author' => $commentAuthor,
67 'authors' => $authors,
69 'others' => $count - 1
73 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
74 'author' => $this->author,
75 'commentAuthor' => $commentAuthor
80 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
82 public function getEmailMessage($notificationType = 'instant') {
83 $comment = new Comment($this->userNotificationObject->commentID);
84 $owner = new User($comment->objectID);
85 if ($comment->userID) {
86 $commentAuthor = new User($comment->userID);
89 $commentAuthor = new User(null, array(
90 'username' => $comment->username
94 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array(
95 'response' => $this->userNotificationObject,
96 'author' => $this->author,
97 'commentAuthor' => $commentAuthor,
99 'notificationType' => $notificationType
104 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
106 public function getLink() {
107 return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
111 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
113 public function getEventHash() {
114 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);