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,
79 'responseID' => $this->getUserNotificationObject()->responseID
83 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
84 'author' => $this->author,
85 'commentAuthor' => $commentAuthor,
86 'commentID' => $this->getUserNotificationObject()->commentID,
87 'responseID' => $this->getUserNotificationObject()->responseID
94 public function getEmailMessage($notificationType = 'instant') {
95 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
96 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
97 if ($comment->userID) {
98 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
101 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
104 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
107 'template' => 'email_notification_userProfileCommentResponseOwner',
108 'application' => 'wcf',
109 'in-reply-to' => [$messageID],
110 'references' => [$messageID],
112 'commentAuthor' => $commentAuthor,
113 'commentID' => $this->getUserNotificationObject()->commentID,
115 'responseID' => $this->getUserNotificationObject()->responseID
123 public function getLink() {
124 return LinkHandler::getInstance()->getLink(
126 ['object' => WCF::getUser()],
127 '#wall/comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID
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')