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\email\Email;
7 use wcf\system\request\LinkHandler;
8 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
12 * User notification event for profile's owner for comment responses.
14 * @author Alexander Ebert
15 * @copyright 2001-2016 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 UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
25 protected $stackable = true;
30 protected function prepare() {
31 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
32 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
38 public function getTitle() {
39 $count = count($this->getAuthors());
41 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
43 'timesTriggered' => $this->notification->timesTriggered
47 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
53 public function getMessage() {
54 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
55 if ($comment->userID) {
56 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
59 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
62 $authors = $this->getAuthors();
63 if (count($authors) > 1) {
64 if (isset($authors[0])) {
67 $count = count($authors);
69 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
70 'author' => $commentAuthor,
71 'authors' => array_values($authors),
73 'others' => $count - 1,
74 'guestTimesTriggered' => $this->notification->guestTimesTriggered
78 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
79 'author' => $this->author,
80 'commentAuthor' => $commentAuthor
87 public function getEmailMessage($notificationType = 'instant') {
88 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
89 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
90 if ($comment->userID) {
91 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
94 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
97 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
100 'template' => 'email_notification_userProfileCommentResponseOwner',
101 'application' => 'wcf',
102 'in-reply-to' => [$messageID],
103 'references' => [$messageID],
105 'commentAuthor' => $commentAuthor,
114 public function getLink() {
115 return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
121 public function getEventHash() {
122 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);