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\LikeUserNotificationObject;
11 * User notification event for profile comment likes.
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 LikeUserNotificationObject getUserNotificationObject()
20 class UserProfileCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentLikeUserNotificationEvent;
22 use TReactionUserNotificationEvent;
27 protected $stackable = true;
32 protected function prepare() {
33 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
39 public function getTitle() {
40 $count = count($this->getAuthors());
42 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.title.stacked', [
44 'timesTriggered' => $this->notification->timesTriggered
48 return $this->getLanguage()->get('wcf.user.notification.comment.like.title');
54 public function getMessage() {
55 $authors = array_values($this->getAuthors());
56 $count = count($authors);
58 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
59 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
63 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', [
64 'author' => $this->author,
65 'authors' => $authors,
66 'commentID' => $this->getCommentID(),
68 'others' => $count - 1,
70 'reactions' => $this->getReactionsForAuthors()
74 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [
75 'author' => $this->author,
76 'commentID' => $this->getCommentID(),
78 'userNotificationObject' => $this->getUserNotificationObject(),
79 'reactions' => $this->getReactionsForAuthors()
86 public function getEmailMessage($notificationType = 'instant') {
87 throw new \LogicException('Unreachable');
93 public function getLink() {
94 $owner = WCF::getUser();
95 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
96 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
99 return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall/comment' . $this->getCommentID());
105 public function getEventHash() {
106 return sha1($this->eventID . '-' . $this->getCommentID());
112 public function supportsEmailNotification() {
117 * Returns the liked comment's id.
121 protected function getCommentID() {
122 // this is the `wcfN_like.objectID` value
123 return $this->getUserNotificationObject()->objectID;
130 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
132 'objectID' => $recipient->userID,
133 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')