2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\User;
4 use wcf\system\comment\CommentDataHandler;
5 use wcf\system\request\LinkHandler;
8 * User notification event for profile commment responses.
10 * @author Alexander Ebert
11 * @copyright 2001-2014 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.user.notification.event
15 * @category Community Framework
17 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent {
19 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
21 protected $stackable = true;
24 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
26 protected function prepare() {
27 CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
28 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']);
29 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
33 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
35 public function getTitle() {
36 $count = count($this->getAuthors());
38 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', array(
40 'timesTriggered' => $this->timesTriggered
44 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
48 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
50 public function getMessage() {
51 // @todo: use cache or a single query to retrieve required data
52 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
53 $owner = CommentDataHandler::getInstance()->getUser($comment->objectID);
54 if ($comment->userID) {
55 $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID);
58 $commentAuthor = new User(null, array(
59 'username' => $comment->username
63 $authors = array_values($this->getAuthors());
64 $count = count($authors);
66 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', array(
67 'authors' => $authors,
69 'others' => $count - 1,
74 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array(
75 'author' => $this->author,
81 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
83 public function getEmailMessage($notificationType = 'instant') {
84 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
85 $user = new User($comment->objectID);
87 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array(
88 'response' => $this->userNotificationObject,
89 'author' => $this->author,
91 'notificationType' => $notificationType
96 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
98 public function getLink() {
99 // @todo: use cache or a single query to retrieve required data
100 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
101 $user = CommentDataHandler::getInstance()->getUser($comment->objectID);
103 return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall');
107 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
109 public function getEventHash() {
110 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);