2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\UserProfile;
4 use wcf\system\cache\runtime\CommentRuntimeCache;
5 use wcf\system\cache\runtime\UserProfileRuntimeCache;
6 use wcf\system\comment\CommentHandler;
7 use wcf\system\email\Email;
8 use wcf\system\request\LinkHandler;
9 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
12 * User notification event for profile's owner for comment responses.
14 * @author Alexander Ebert
15 * @copyright 2001-2018 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\User\Notification\Event
19 * @method CommentResponseUserNotificationObject getUserNotificationObject()
21 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
22 use TTestableCommentResponseUserNotificationEvent;
27 protected $stackable = true;
32 protected function prepare() {
33 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
34 UserProfileRuntimeCache::getInstance()->cacheObjectIDs([
35 $this->additionalData['userID'],
36 $this->additionalData['objectID']
43 public function getTitle() {
44 $count = count($this->getAuthors());
46 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
48 'timesTriggered' => $this->notification->timesTriggered
52 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
58 public function getMessage() {
59 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
60 if ($comment->userID) {
61 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
64 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
67 $authors = $this->getAuthors();
68 if (count($authors) > 1) {
69 if (isset($authors[0])) {
72 $count = count($authors);
74 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
75 'author' => $commentAuthor,
76 'authors' => array_values($authors),
78 'others' => $count - 1,
79 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
80 'commentID' => $this->getUserNotificationObject()->commentID
84 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
85 'author' => $this->author,
86 'commentAuthor' => $commentAuthor,
87 'commentID' => $this->getUserNotificationObject()->commentID,
88 'responseID' => $this->getUserNotificationObject()->responseID
95 public function getEmailMessage($notificationType = 'instant') {
96 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
97 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
98 if ($comment->userID) {
99 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
102 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
105 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
108 'template' => 'email_notification_commentResponseOwner',
109 'application' => 'wcf',
110 'in-reply-to' => [$messageID],
111 'references' => [$messageID],
113 'commentAuthor' => $commentAuthor,
114 'commentID' => $this->getUserNotificationObject()->commentID,
116 'responseID' => $this->getUserNotificationObject()->responseID,
117 'languageVariablePrefix' => 'wcf.user.notification.commentResponseOwner'
125 public function getLink() {
126 return LinkHandler::getInstance()->getLink(
128 ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])],
129 '#wall/comment' . $this->getUserNotificationObject()->commentID
136 public function getEventHash() {
137 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
144 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
146 'objectID' => $recipient->userID,
147 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')