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-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 UserProfileCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableCommentResponseLikeUserNotificationEvent;
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()
78 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', [
79 'author' => $this->author,
80 'commentID' => $this->additionalData['commentID'],
82 'responseID' => $this->getResponseID()
89 public function getEmailMessage($notificationType = 'instant') {
90 throw new \LogicException('Unreachable');
96 public function getLink() {
97 $owner = WCF::getUser();
98 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
99 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
102 return LinkHandler::getInstance()->getLink(
104 ['object' => $owner],
105 '#wall/comment' . $this->additionalData['commentID'] . '/response' . $this->getResponseID()
112 public function getEventHash() {
113 return sha1($this->eventID . '-' . $this->additionalData['commentID']);
119 public function supportsEmailNotification() {
124 * Returns the liked response's id.
128 protected function getResponseID() {
129 // this is the `wcfN_like.objectID` value
130 return $this->getUserNotificationObject()->objectID;
137 protected static function getTestCommentObjectData(UserProfile $recipient, UserProfile $author) {
139 'objectID' => $recipient->userID,
140 'objectTypeID' => CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.user.profileComment')