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\LikeUserNotificationObject;
12 * User notification event for profile comment likes.
14 * @author Alexander Ebert
15 * @copyright 2001-2018 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\User\Notification\Event
19 * @method LikeUserNotificationObject getUserNotificationObject()
21 class UserProfileCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
22 use TTestableCommentLikeUserNotificationEvent;
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,
73 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [
74 'author' => $this->author,
75 'commentID' => $this->getCommentID(),
83 public function getEmailMessage($notificationType = 'instant') {
84 throw new \LogicException('Unreachable');
90 public function getLink() {
91 $owner = WCF::getUser();
92 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
93 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
96 return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall/comment' . $this->getCommentID());
102 public function getEventHash() {
103 return sha1($this->eventID . '-' . $this->getCommentID());
109 public function supportsEmailNotification() {
114 * Returns the liked comment's id.
118 protected function getCommentID() {
119 // this is the `wcfN_like.objectID` value
120 return $this->getUserNotificationObject()->objectID;
127 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
129 'objectID' => $recipient->userID,
130 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')