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 commment 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
100 $authors = $this->getAuthors();
101 if (count($authors) > 1) {
102 if (isset($authors[0])) {
105 $count = count($authors);
107 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', [
108 'author' => $this->author,
109 'authors' => array_values($authors),
110 'commentAuthor' => $commentAuthor,
112 'notificationType' => $notificationType,
113 'others' => $count - 1,
115 'response' => $this->userNotificationObject,
116 'guestTimesTriggered' => $this->notification->guestTimesTriggered
120 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', [
121 'response' => $this->userNotificationObject,
122 'author' => $this->author,
123 'commentAuthor' => $commentAuthor,
125 'notificationType' => $notificationType
132 public function getLink() {
133 return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
139 public function getEventHash() {
140 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);