03c3d393f2fa88facc2d6afa0bf3d73a442dd4ef
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 namespace wcf\system\user\notification\event;
4
5 use wcf\system\cache\runtime\UserRuntimeCache;
6 use wcf\system\cache\runtime\ViewableArticleContentRuntimeCache;
7 use wcf\system\user\notification\event\AbstractSharedUserNotificationEvent;
8 use wcf\system\user\notification\event\ITestableUserNotificationEvent;
9 use wcf\system\user\notification\event\TReactionUserNotificationEvent;
10 use wcf\system\user\notification\event\TTestableCommentResponseLikeUserNotificationEvent;
11 use wcf\system\user\notification\object\LikeUserNotificationObject;
12 use wcf\system\WCF;
13
14 /**
15 * User notification event for article comment response likes.
16 *
17 * @author Marcel Werk
18 * @copyright 2001-2022 WoltLab GmbH
19 * @license WoltLab License <http://www.woltlab.com/license-agreement.html>
20 * @package WoltLabSuite\Core\System\User\Notification\Event
21 * @since 5.5
22 *
23 * @method LikeUserNotificationObject getUserNotificationObject()
24 */
25 class ArticleCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
26 ITestableUserNotificationEvent
27 {
28 use TTestableCommentResponseLikeUserNotificationEvent;
29 use TTestableArticleCommentUserNotificationEvent;
30 use TReactionUserNotificationEvent;
31
32 /**
33 * @inheritDoc
34 */
35 protected $stackable = true;
36
37 /**
38 * @inheritDoc
39 */
40 protected function prepare()
41 {
42 ViewableArticleContentRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
43 UserRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']);
44 }
45
46 /**
47 * @inheritDoc
48 */
49 public function getTitle()
50 {
51 $count = \count($this->getAuthors());
52 if ($count > 1) {
53 return $this->getLanguage()->getDynamicVariable(
54 'wcf.user.notification.articleComment.response.like.title.stacked',
55 [
56 'count' => $count,
57 'timesTriggered' => $this->notification->timesTriggered,
58 ]
59 );
60 }
61
62 return $this->getLanguage()->get('wcf.user.notification.articleComment.response.like.title');
63 }
64
65 /**
66 * @inheritDoc
67 */
68 public function getMessage()
69 {
70 $article = ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
71 $authors = \array_values($this->getAuthors());
72 $count = \count($authors);
73 $commentUser = null;
74 if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
75 $commentUser = UserRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']);
76 }
77
78 if ($count > 1) {
79 return $this->getLanguage()->getDynamicVariable(
80 'wcf.user.notification.articleComment.response.like.message.stacked',
81 [
82 'author' => $this->author,
83 'authors' => $authors,
84 'commentID' => $this->additionalData['commentID'],
85 'commentUser' => $commentUser,
86 'count' => $count,
87 'others' => $count - 1,
88 'article' => $article,
89 'responseID' => $this->getUserNotificationObject()->objectID,
90 'reactions' => $this->getReactionsForAuthors(),
91 ]
92 );
93 }
94
95 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.like.message', [
96 'author' => $this->author,
97 'commentID' => $this->additionalData['commentID'],
98 'article' => $article,
99 'responseID' => $this->getUserNotificationObject()->objectID,
100 'reactions' => $this->getReactionsForAuthors(),
101 ]);
102 }
103
104 /**
105 * @inheritDoc
106 */
107 public function getEmailMessage($notificationType = 'instant')
108 {
109 // not supported
110 }
111
112 /**
113 * @inheritDoc
114 */
115 public function getLink()
116 {
117 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink()
118 . '#comment' . $this->additionalData['commentID'] . '/response' . $this->getUserNotificationObject()->objectID;
119 }
120
121 /**
122 * @inheritDoc
123 */
124 public function getEventHash()
125 {
126 return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
127 }
128
129 /**
130 * @inheritDoc
131 */
132 public function supportsEmailNotification()
133 {
134 return false;
135 }
136 }