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\email\Email;
9 use wcf\system\request\LinkHandler;
10 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
14 * User notification event for profile's owner for comment responses.
16 * @author Alexander Ebert
17 * @copyright 2001-2016 WoltLab GmbH
18 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @package WoltLabSuite\Core\System\User\Notification\Event
21 * @method CommentResponseUserNotificationObject getUserNotificationObject()
23 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
27 protected $stackable = true;
32 protected function prepare() {
33 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
34 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
40 public function getTitle() {
41 $count = count($this->getAuthors());
43 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
45 'timesTriggered' => $this->notification->timesTriggered
49 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
55 public function getMessage() {
56 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
57 if ($comment->userID) {
58 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
61 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
64 $authors = $this->getAuthors();
65 if (count($authors) > 1) {
66 if (isset($authors[0])) {
69 $count = count($authors);
71 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
72 'author' => $commentAuthor,
73 'authors' => array_values($authors),
75 'others' => $count - 1,
76 'guestTimesTriggered' => $this->notification->guestTimesTriggered
80 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
81 'author' => $this->author,
82 'commentAuthor' => $commentAuthor
89 public function getEmailMessage($notificationType = 'instant') {
90 $comment = new Comment($this->getUserNotificationObject()->commentID);
91 $owner = new User($comment->objectID);
92 if ($comment->userID) {
93 $commentAuthor = new User($comment->userID);
96 $commentAuthor = new User(null, [
97 'username' => $comment->username
101 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
104 'template' => 'email_notification_userProfileCommentResponseOwner',
105 'application' => 'wcf',
106 'in-reply-to' => [$messageID],
107 'references' => [$messageID],
109 'commentAuthor' => $commentAuthor,
118 public function getLink() {
119 return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
125 public function getEventHash() {
126 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);