3 namespace wcf\system\user\notification\event;
5 use wcf\data\user\UserProfile;
6 use wcf\system\cache\runtime\CommentRuntimeCache;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache;
8 use wcf\system\comment\CommentHandler;
9 use wcf\system\email\Email;
10 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
13 * User notification event for profile comment responses.
15 * @author Alexander Ebert
16 * @copyright 2001-2019 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @method CommentResponseUserNotificationObject getUserNotificationObject()
21 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
22 ITestableUserNotificationEvent
24 use TTestableCommentResponseUserNotificationEvent;
29 protected $stackable = true;
34 protected function prepare()
36 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
37 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
43 public function getTitle(): string
45 $count = \count($this->getAuthors());
47 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [
49 'timesTriggered' => $this->notification->timesTriggered,
53 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
59 public function getMessage()
61 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
63 $authors = $this->getAuthors();
64 if (\count($authors) > 1) {
65 if (isset($authors[0])) {
68 $count = \count($authors);
70 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
71 'authors' => \array_values($authors),
72 'commentID' => $this->getUserNotificationObject()->commentID,
74 'others' => $count - 1,
76 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
80 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
81 'author' => $this->author,
82 'commentID' => $this->getUserNotificationObject()->commentID,
84 'responseID' => $this->getUserNotificationObject()->responseID,
91 public function getEmailMessage($notificationType = 'instant')
93 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
94 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
96 $messageID = '<com.woltlab.wcf.user.profileComment.notification/' . $comment->commentID . '@' . Email::getHost() . '>';
99 'template' => 'email_notification_commentResponse',
100 'application' => 'wcf',
101 'in-reply-to' => [$messageID],
102 'references' => [$messageID],
104 'commentID' => $this->getUserNotificationObject()->commentID,
106 'responseID' => $this->getUserNotificationObject()->responseID,
107 'languageVariablePrefix' => 'wcf.user.notification.commentResponse',
115 public function getLink(): string
117 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall/comment' . $this->getUserNotificationObject()->commentID;
123 public function getEventHash()
125 return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
132 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author)
135 'objectID' => $author->userID,
136 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment'),