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\user\notification\object\LikeUserNotificationObject;
10 * User notification event for profile comment likes.
12 * @author Alexander Ebert
13 * @copyright 2001-2019 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 LikeUserNotificationObject getUserNotificationObject()
19 class UserProfileCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
20 use TTestableCommentLikeUserNotificationEvent;
21 use TReactionUserNotificationEvent;
26 protected $stackable = true;
31 protected function prepare() {
32 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
38 public function getTitle() {
39 $count = count($this->getAuthors());
41 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.title.stacked', [
43 'timesTriggered' => $this->notification->timesTriggered
47 return $this->getLanguage()->get('wcf.user.notification.comment.like.title');
53 public function getMessage() {
54 $authors = array_values($this->getAuthors());
55 $count = count($authors);
57 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
58 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
62 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', [
63 'author' => $this->author,
64 'authors' => $authors,
65 'commentID' => $this->getCommentID(),
67 'others' => $count - 1,
69 'reactions' => $this->getReactionsForAuthors()
73 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [
74 'author' => $this->author,
75 'commentID' => $this->getCommentID(),
77 'userNotificationObject' => $this->getUserNotificationObject(),
78 'reactions' => $this->getReactionsForAuthors()
85 public function getEmailMessage($notificationType = 'instant') {
86 throw new \LogicException('Unreachable');
92 public function getLink() {
93 $owner = WCF::getUser();
94 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
95 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
98 return $owner->getLink() . '#wall/comment' . $this->getCommentID();
104 public function getEventHash() {
105 return sha1($this->eventID . '-' . $this->getCommentID());
111 public function supportsEmailNotification() {
116 * Returns the liked comment's id.
120 protected function getCommentID() {
121 // this is the `wcfN_like.objectID` value
122 return $this->getUserNotificationObject()->objectID;
129 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
131 'objectID' => $recipient->userID,
132 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')