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;
13 * User notification event for profile's owner for comment responses.
15 * @author Alexander Ebert
16 * @copyright 2001-2017 WoltLab GmbH
17 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
18 * @package WoltLabSuite\Core\System\User\Notification\Event
20 * @method CommentResponseUserNotificationObject getUserNotificationObject()
22 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
23 use TTestableCommentResponseUserNotificationEvent;
28 protected $stackable = true;
33 protected function prepare() {
34 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
35 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
41 public function getTitle() {
42 $count = count($this->getAuthors());
44 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
46 'timesTriggered' => $this->notification->timesTriggered
50 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
56 public function getMessage() {
57 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
58 if ($comment->userID) {
59 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
62 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
65 $authors = $this->getAuthors();
66 if (count($authors) > 1) {
67 if (isset($authors[0])) {
70 $count = count($authors);
72 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
73 'author' => $commentAuthor,
74 'authors' => array_values($authors),
76 'others' => $count - 1,
77 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
78 'commentID' => $this->getUserNotificationObject()->commentID
82 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
83 'author' => $this->author,
84 'commentAuthor' => $commentAuthor,
85 'commentID' => $this->getUserNotificationObject()->commentID,
86 'responseID' => $this->getUserNotificationObject()->responseID
93 public function getEmailMessage($notificationType = 'instant') {
94 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
95 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
96 if ($comment->userID) {
97 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
100 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
103 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
106 'template' => 'email_notification_commentResponseOwner',
107 'application' => 'wcf',
108 'in-reply-to' => [$messageID],
109 'references' => [$messageID],
111 'commentAuthor' => $commentAuthor,
112 'commentID' => $this->getUserNotificationObject()->commentID,
114 'responseID' => $this->getUserNotificationObject()->responseID,
115 'languageVariablePrefix' => 'wcf.user.notification.commentResponseOwner'
123 public function getLink() {
124 return LinkHandler::getInstance()->getLink(
126 ['object' => WCF::getUser()],
127 '#wall/comment' . $this->getUserNotificationObject()->commentID
134 public function getEventHash() {
135 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
142 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
144 'objectID' => $recipient->userID,
145 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')