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-2017 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;
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,
72 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [
73 'author' => $this->author,
74 'commentID' => $this->getCommentID(),
82 public function getEmailMessage($notificationType = 'instant') {
83 throw new \LogicException('Unreachable');
89 public function getLink() {
90 $owner = WCF::getUser();
91 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
92 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
95 return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall/comment' . $this->getCommentID());
101 public function getEventHash() {
102 return sha1($this->eventID . '-' . $this->getCommentID());
108 public function supportsEmailNotification() {
113 * Returns the liked comment's id.
117 protected function getCommentID() {
118 // this is the `wcfN_like.objectID` value
119 return $this->getUserNotificationObject()->objectID;
126 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
128 'objectID' => $recipient->userID,
129 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')