2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\UserProfile;
4 use wcf\system\cache\runtime\UserProfileRuntimeCache;
5 use wcf\system\comment\CommentHandler;
6 use wcf\system\request\LinkHandler;
7 use wcf\system\user\notification\object\CommentUserNotificationObject;
10 * User notification event for profile comments.
12 * @author Alexander Ebert
13 * @copyright 2001-2018 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\System\User\Notification\Event
17 * @method CommentUserNotificationObject getUserNotificationObject()
19 class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
20 use TTestableCommentUserNotificationEvent;
25 protected $stackable = true;
30 protected function prepare() {
31 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
37 public function getTitle() {
38 $count = count($this->getAuthors());
40 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', [
42 'timesTriggered' => $this->notification->timesTriggered
46 return $this->getLanguage()->get('wcf.user.notification.comment.title');
52 public function getMessage() {
53 $authors = $this->getAuthors();
54 if (count($authors) > 1) {
55 if (isset($authors[0])) {
58 $count = count($authors);
60 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', [
61 'author' => $this->author,
62 'authors' => array_values($authors),
63 'commentID' => $this->getUserNotificationObject()->commentID,
65 'others' => $count - 1,
66 'guestTimesTriggered' => $this->notification->guestTimesTriggered
70 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', [
71 'author' => $this->author,
72 'commentID' => $this->getUserNotificationObject()->commentID
79 public function getEmailMessage($notificationType = 'instant') {
81 'message-id' => 'com.woltlab.wcf.user.profileComment.notification/'.$this->getUserNotificationObject()->commentID,
82 'template' => 'email_notification_comment',
83 'application' => 'wcf',
85 'commentID' => $this->getUserNotificationObject()->commentID,
86 'owner' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID),
87 'languageVariablePrefix' => 'wcf.user.notification.comment'
95 public function getLink() {
96 return LinkHandler::getInstance()->getLink(
98 ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)],
99 '#wall/comment' . $this->getUserNotificationObject()->commentID
106 public function getEventHash() {
107 return sha1($this->eventID . '-' . $this->notification->userID);
114 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
116 'objectID' => $recipient->userID,
117 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')