2 namespace wcf\system\user\notification\event;
3 use wcf\data\comment\Comment;
4 use wcf\data\user\User;
5 use wcf\data\user\UserProfile;
6 use wcf\system\cache\runtime\CommentRuntimeCache;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache;
8 use wcf\system\request\LinkHandler;
12 * User notification event for profile's owner for commment responses.
14 * @author Alexander Ebert
15 * @copyright 2001-2016 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package com.woltlab.wcf
18 * @subpackage system.user.notification.event
19 * @category Community Framework
21 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
25 protected $stackable = true;
30 protected function prepare() {
31 CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID);
32 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
38 public function getTitle() {
39 $count = count($this->getAuthors());
41 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
43 'timesTriggered' => $this->notification->timesTriggered
47 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
53 public function getMessage() {
54 $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
55 if ($comment->userID) {
56 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
59 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
62 $authors = $this->getAuthors();
63 if (count($authors) > 1) {
64 if (isset($authors[0])) {
67 $count = count($authors);
69 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
70 'author' => $commentAuthor,
71 'authors' => array_values($authors),
73 'others' => $count - 1,
74 'guestTimesTriggered' => $this->notification->guestTimesTriggered
78 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
79 'author' => $this->author,
80 'commentAuthor' => $commentAuthor
87 public function getEmailMessage($notificationType = 'instant') {
88 $comment = new Comment($this->userNotificationObject->commentID);
89 $owner = new User($comment->objectID);
90 if ($comment->userID) {
91 $commentAuthor = new User($comment->userID);
94 $commentAuthor = new User(null, [
95 'username' => $comment->username
99 $authors = $this->getAuthors();
100 if (count($authors) > 1) {
101 if (isset($authors[0])) {
104 $count = count($authors);
106 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', [
107 'author' => $this->author,
108 'authors' => array_values($authors),
109 'commentAuthor' => $commentAuthor,
111 'notificationType' => $notificationType,
112 'others' => $count - 1,
114 'response' => $this->userNotificationObject,
115 'guestTimesTriggered' => $this->notification->guestTimesTriggered
119 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', [
120 'response' => $this->userNotificationObject,
121 'author' => $this->author,
122 'commentAuthor' => $commentAuthor,
124 'notificationType' => $notificationType
131 public function getLink() {
132 return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
138 public function getEventHash() {
139 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);