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\user\notification\object\CommentResponseUserNotificationObject;
11 * User notification event for profile comment responses.
13 * @author Alexander Ebert
14 * @copyright 2001-2018 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\User\Notification\Event
18 * @method CommentResponseUserNotificationObject getUserNotificationObject()
20 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentResponseUserNotificationEvent;
26 protected $stackable = true;
31 protected function prepare() {
32 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
33 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
39 public function getTitle() {
40 $count = count($this->getAuthors());
42 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [
44 'timesTriggered' => $this->notification->timesTriggered
48 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
54 public function getMessage() {
55 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
57 $authors = $this->getAuthors();
58 if (count($authors) > 1) {
59 if (isset($authors[0])) {
62 $count = count($authors);
64 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
65 'authors' => array_values($authors),
66 'commentID' => $this->getUserNotificationObject()->commentID,
68 'others' => $count - 1,
70 'guestTimesTriggered' => $this->notification->guestTimesTriggered
74 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
75 'author' => $this->author,
76 'commentID' => $this->getUserNotificationObject()->commentID,
78 'responseID' => $this->getUserNotificationObject()->responseID
85 public function getEmailMessage($notificationType = 'instant') {
86 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
87 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
89 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
92 'template' => 'email_notification_commentResponse',
93 'application' => 'wcf',
94 'in-reply-to' => [$messageID],
95 'references' => [$messageID],
97 'commentID' => $this->getUserNotificationObject()->commentID,
99 'responseID' => $this->getUserNotificationObject()->responseID,
100 'languageVariablePrefix' => 'wcf.user.notification.commentResponse'
108 public function getLink() {
109 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall/comment' . $this->getUserNotificationObject()->commentID;
115 public function getEventHash() {
116 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
123 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
125 'objectID' => $author->userID,
126 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')