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;
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-2016 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 {
26 protected $stackable = true;
31 protected function prepare() {
32 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
33 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
39 public function getTitle() {
40 $count = count($this->getAuthors());
42 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
44 'timesTriggered' => $this->notification->timesTriggered
48 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
54 public function getMessage() {
55 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
56 if ($comment->userID) {
57 $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
60 $commentAuthor = UserProfile::getGuestUserProfile($comment->username);
63 $authors = $this->getAuthors();
64 if (count($authors) > 1) {
65 if (isset($authors[0])) {
68 $count = count($authors);
70 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
71 'author' => $commentAuthor,
72 'authors' => array_values($authors),
74 'others' => $count - 1,
75 'guestTimesTriggered' => $this->notification->guestTimesTriggered
79 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
80 'author' => $this->author,
81 'commentAuthor' => $commentAuthor
88 public function getEmailMessage($notificationType = 'instant') {
89 $comment = new Comment($this->getUserNotificationObject()->commentID);
90 $owner = new User($comment->objectID);
91 if ($comment->userID) {
92 $commentAuthor = new User($comment->userID);
95 $commentAuthor = new User(null, [
96 'username' => $comment->username
101 'template' => 'email_notification_userProfileCommentResponseOwner',
102 'application' => 'wcf',
104 'commentAuthor' => $commentAuthor,
113 public function getLink() {
114 return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
120 public function getEventHash() {
121 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);