352b027e579c078e1dce8f356e654b2d76369fc3
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 namespace wcf\system\user\notification\event;
4
5 use wcf\system\cache\runtime\CommentRuntimeCache;
6 use wcf\system\cache\runtime\ViewableArticleContentRuntimeCache;
7 use wcf\system\email\Email;
8 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
9
10 /**
11 * User notification event for article comment responses.
12 *
13 * @author Joshua Ruesweg
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @since 5.2
17 *
18 * @method CommentResponseUserNotificationObject getUserNotificationObject()
19 */
20 class ArticleCommentResponseUserNotificationEvent extends AbstractCommentResponseUserNotificationEvent implements
21 ITestableUserNotificationEvent
22 {
23 use TTestableCommentResponseUserNotificationEvent;
24 use TTestableArticleCommentUserNotificationEvent;
25
26 /**
27 * @inheritDoc
28 */
29 protected function prepare()
30 {
31 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
32 }
33
34 /**
35 * @inheritDoc
36 */
37 public function getMessage()
38 {
39 $authors = $this->getAuthors();
40 if (\count($authors) > 1) {
41 if (isset($authors[0])) {
42 unset($authors[0]);
43 }
44 $count = \count($authors);
45
46 return $this->getLanguage()->getDynamicVariable(
47 'wcf.user.notification.articleComment.response.message.stacked',
48 [
49 'author' => $this->author,
50 'authors' => \array_values($authors),
51 'commentID' => $this->getUserNotificationObject()->commentID,
52 'article' => ViewableArticleContentRuntimeCache::getInstance()
53 ->getObject($this->additionalData['objectID']),
54 'count' => $count,
55 'others' => $count - 1,
56 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
57 'responseID' => $this->getUserNotificationObject()->responseID,
58 ]
59 );
60 }
61
62 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.message', [
63 'author' => $this->author,
64 'commentID' => $this->getUserNotificationObject()->commentID,
65 'article' => ViewableArticleContentRuntimeCache::getInstance()
66 ->getObject($this->additionalData['objectID']),
67 'responseID' => $this->getUserNotificationObject()->responseID,
68 ]);
69 }
70
71 /**
72 * @inheritDoc
73 */
74 public function getEmailMessage($notificationType = 'instant')
75 {
76 $messageID = '<com.woltlab.wcf.user.articleComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
77
78 return [
79 'template' => 'email_notification_commentResponse',
80 'in-reply-to' => [$messageID],
81 'references' => [$messageID],
82 'application' => 'wcf',
83 'variables' => [
84 'commentID' => $this->getUserNotificationObject()->commentID,
85 'article' => ViewableArticleContentRuntimeCache::getInstance()
86 ->getObject($this->additionalData['objectID']),
87 'languageVariablePrefix' => 'wcf.user.notification.articleComment.response',
88 'responseID' => $this->getUserNotificationObject()->responseID,
89 ],
90 ];
91 }
92
93 /**
94 * @inheritDoc
95 */
96 public function getLink(): string
97 {
98 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
99 }
100
101 /**
102 * @inheritDoc
103 */
104 protected function getTypeName(): string
105 {
106 return $this->getLanguage()->get('wcf.user.recentActivity.com.woltlab.wcf.article.recentActivityEvent');
107 }
108
109 /**
110 * @inheritDoc
111 */
112 protected function getObjectTitle(): string
113 {
114 return ViewableArticleContentRuntimeCache::getInstance()
115 ->getObject($this->additionalData['objectID'])->getTitle();
116 }
117 }