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-2017 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,
71 'responseID' => $this->getUserNotificationObject()->responseID
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_userProfileCommentResponse',
94 'application' => 'wcf',
95 'in-reply-to' => [$messageID],
96 'references' => [$messageID],
98 'commentID' => $this->getUserNotificationObject()->commentID,
100 'responseID' => $this->getUserNotificationObject()->responseID
108 public function getLink() {
109 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall/comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
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')