2 declare(strict_types=1);
3 namespace wcf\system\user\notification\event;
4 use wcf\data\user\UserProfile;
5 use wcf\system\cache\runtime\UserProfileRuntimeCache;
6 use wcf\system\comment\CommentHandler;
7 use wcf\system\request\LinkHandler;
8 use wcf\system\user\notification\object\CommentUserNotificationObject;
11 * User notification event for profile comments.
13 * @author Alexander Ebert
14 * @copyright 2001-2018 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\User\Notification\Event
18 * @method CommentUserNotificationObject getUserNotificationObject()
20 class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentUserNotificationEvent;
26 protected $stackable = true;
31 protected function prepare() {
32 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
38 public function getTitle() {
39 $count = count($this->getAuthors());
41 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', [
43 'timesTriggered' => $this->notification->timesTriggered
47 return $this->getLanguage()->get('wcf.user.notification.comment.title');
53 public function getMessage() {
54 $authors = $this->getAuthors();
55 if (count($authors) > 1) {
56 if (isset($authors[0])) {
59 $count = count($authors);
61 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', [
62 'author' => $this->author,
63 'authors' => array_values($authors),
64 'commentID' => $this->getUserNotificationObject()->commentID,
66 'others' => $count - 1,
67 'guestTimesTriggered' => $this->notification->guestTimesTriggered
71 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', [
72 'author' => $this->author,
73 'commentID' => $this->getUserNotificationObject()->commentID
80 public function getEmailMessage($notificationType = 'instant') {
82 'message-id' => 'com.woltlab.wcf.user.profileComment.notification/'.$this->getUserNotificationObject()->commentID,
83 'template' => 'email_notification_comment',
84 'application' => 'wcf',
86 'commentID' => $this->getUserNotificationObject()->commentID,
87 'owner' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID),
88 'languageVariablePrefix' => 'wcf.user.notification.comment'
96 public function getLink() {
97 return LinkHandler::getInstance()->getLink(
99 ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)],
100 '#wall/comment' . $this->getUserNotificationObject()->commentID
107 public function getEventHash() {
108 return sha1($this->eventID . '-' . $this->notification->userID);
115 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
117 'objectID' => $recipient->userID,
118 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')