2 namespace wcf\system\user\notification\event;
3 use wcf\data\comment\Comment;
4 use wcf\data\user\User;
5 use wcf\data\user\UserProfile;
6 use wcf\system\cache\runtime\CommentRuntimeCache;
7 use wcf\system\cache\runtime\UserProfileRuntimeCache;
8 use wcf\system\request\LinkHandler;
12 * User notification event for profile's owner for commment 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 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
23 protected $stackable = true;
28 protected function prepare() {
29 CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID);
30 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
36 public function getTitle() {
37 $count = count($this->getAuthors());
39 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
41 'timesTriggered' => $this->notification->timesTriggered
45 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
51 public function getMessage() {
52 $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
53 if ($comment->userID) {
54 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
57 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
60 $authors = $this->getAuthors();
61 if (count($authors) > 1) {
62 if (isset($authors[0])) {
65 $count = count($authors);
67 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
68 'author' => $commentAuthor,
69 'authors' => array_values($authors),
71 'others' => $count - 1,
72 'guestTimesTriggered' => $this->notification->guestTimesTriggered
76 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
77 'author' => $this->author,
78 'commentAuthor' => $commentAuthor
85 public function getEmailMessage($notificationType = 'instant') {
86 $comment = new Comment($this->userNotificationObject->commentID);
87 $owner = new User($comment->objectID);
88 if ($comment->userID) {
89 $commentAuthor = new User($comment->userID);
92 $commentAuthor = new User(null, [
93 'username' => $comment->username
97 $authors = $this->getAuthors();
98 if (count($authors) > 1) {
99 if (isset($authors[0])) {
102 $count = count($authors);
104 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', [
105 'author' => $this->author,
106 'authors' => array_values($authors),
107 'commentAuthor' => $commentAuthor,
109 'notificationType' => $notificationType,
110 'others' => $count - 1,
112 'response' => $this->userNotificationObject,
113 'guestTimesTriggered' => $this->notification->guestTimesTriggered
117 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', [
118 'response' => $this->userNotificationObject,
119 'author' => $this->author,
120 'commentAuthor' => $commentAuthor,
122 'notificationType' => $notificationType
129 public function getLink() {
130 return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
136 public function getEventHash() {
137 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);