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 response 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 UserProfileCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentResponseLikeUserNotificationEvent;
22 use TReactionUserNotificationEvent;
27 protected $stackable = true;
32 protected function prepare() {
33 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
34 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']);
40 public function getTitle() {
41 $count = count($this->getAuthors());
43 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', [
45 'timesTriggered' => $this->notification->timesTriggered
49 return $this->getLanguage()->get('wcf.user.notification.commentResponse.like.title');
55 public function getMessage() {
56 $authors = array_values($this->getAuthors());
57 $count = count($authors);
58 $commentUser = $owner = null;
59 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
60 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
62 if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
63 $commentUser = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']);
67 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', [
68 'author' => $this->author,
69 'authors' => $authors,
70 'commentID' => $this->additionalData['commentID'],
71 'commentUser' => $commentUser,
73 'others' => $count - 1,
75 'responseID' => $this->getResponseID(),
76 'reactions' => $this->getReactionsForAuthors()
80 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', [
81 'author' => $this->author,
82 'commentID' => $this->additionalData['commentID'],
84 'responseID' => $this->getResponseID(),
85 'userNotificationObject' => $this->getUserNotificationObject(),
86 'reactions' => $this->getReactionsForAuthors()
93 public function getEmailMessage($notificationType = 'instant') {
94 throw new \LogicException('Unreachable');
100 public function getLink() {
101 $owner = WCF::getUser();
102 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
103 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
106 return LinkHandler::getInstance()->getLink(
108 ['object' => $owner],
109 '#wall/comment' . $this->additionalData['commentID'] . '/response' . $this->getResponseID()
116 public function getEventHash() {
117 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
123 public function supportsEmailNotification() {
128 * Returns the liked response's id.
132 protected function getResponseID() {
133 // this is the `wcfN_like.objectID` value
134 return $this->getUserNotificationObject()->objectID;
141 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
143 'objectID' => $recipient->userID,
144 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')