2 declare(strict_types=1);
3 namespace wcf\system\user\notification\event;
4 use wcf\data\user\UserProfile;
5 use wcf\system\cache\runtime\CommentRuntimeCache;
6 use wcf\system\cache\runtime\UserProfileRuntimeCache;
7 use wcf\system\comment\CommentHandler;
8 use wcf\system\email\Email;
9 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
12 * User notification event for profile 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 UserProfileCommentResponseUserNotificationEvent 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()->cacheObjectID($this->additionalData['objectID']);
40 public function getTitle() {
41 $count = count($this->getAuthors());
43 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [
45 'timesTriggered' => $this->notification->timesTriggered
49 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
55 public function getMessage() {
56 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
58 $authors = $this->getAuthors();
59 if (count($authors) > 1) {
60 if (isset($authors[0])) {
63 $count = count($authors);
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
66 'authors' => array_values($authors),
67 'commentID' => $this->getUserNotificationObject()->commentID,
69 'others' => $count - 1,
71 'guestTimesTriggered' => $this->notification->guestTimesTriggered
75 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
76 'author' => $this->author,
77 'commentID' => $this->getUserNotificationObject()->commentID,
79 'responseID' => $this->getUserNotificationObject()->responseID
86 public function getEmailMessage($notificationType = 'instant') {
87 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
88 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
90 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
93 'template' => 'email_notification_commentResponse',
94 'application' => 'wcf',
95 'in-reply-to' => [$messageID],
96 'references' => [$messageID],
98 'commentID' => $this->getUserNotificationObject()->commentID,
100 'responseID' => $this->getUserNotificationObject()->responseID,
101 'languageVariablePrefix' => 'wcf.user.notification.commentResponse'
109 public function getLink() {
110 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall/comment' . $this->getUserNotificationObject()->commentID;
116 public function getEventHash() {
117 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
124 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
126 'objectID' => $author->userID,
127 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')