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 response 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 UserProfileCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
20 use TTestableCommentResponseLikeUserNotificationEvent;
21 use TReactionUserNotificationEvent;
26 protected $stackable = true;
31 protected function prepare() {
32 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
33 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']);
39 public function getTitle() {
40 $count = count($this->getAuthors());
42 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', [
44 'timesTriggered' => $this->notification->timesTriggered
48 return $this->getLanguage()->get('wcf.user.notification.commentResponse.like.title');
54 public function getMessage() {
55 $authors = array_values($this->getAuthors());
56 $count = count($authors);
57 $commentUser = $owner = null;
58 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
59 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
61 if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
62 $commentUser = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']);
66 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', [
67 'author' => $this->author,
68 'authors' => $authors,
69 'commentID' => $this->additionalData['commentID'],
70 'commentUser' => $commentUser,
72 'others' => $count - 1,
74 'responseID' => $this->getResponseID(),
75 'reactions' => $this->getReactionsForAuthors()
79 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', [
80 'author' => $this->author,
81 'commentID' => $this->additionalData['commentID'],
83 'responseID' => $this->getResponseID(),
84 'userNotificationObject' => $this->getUserNotificationObject(),
85 'reactions' => $this->getReactionsForAuthors()
92 public function getEmailMessage($notificationType = 'instant') {
93 throw new \LogicException('Unreachable');
99 public function getLink() {
100 $owner = WCF::getUser();
101 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
102 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
105 return $owner->getLink() . '#wall/comment' . $this->additionalData['commentID'] . '/response' . $this->getResponseID();
111 public function getEventHash() {
112 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
118 public function supportsEmailNotification() {
123 * Returns the liked response's id.
127 protected function getResponseID() {
128 // this is the `wcfN_like.objectID` value
129 return $this->getUserNotificationObject()->objectID;
136 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
138 'objectID' => $recipient->userID,
139 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')