c2df7ac315d49d73b495d5463b522ab90e351853
[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 class ArticleCommentResponseUserNotificationEvent extends AbstractCommentResponseUserNotificationEvent implements
19 ITestableUserNotificationEvent
20 {
21 use TTestableCommentResponseUserNotificationEvent;
22 use TTestableArticleCommentUserNotificationEvent;
23
24 /**
25 * @inheritDoc
26 */
27 public function getMessage()
28 {
29 $authors = $this->getAuthors();
30 if (\count($authors) > 1) {
31 if (isset($authors[0])) {
32 unset($authors[0]);
33 }
34 $count = \count($authors);
35
36 return $this->getLanguage()->getDynamicVariable(
37 'wcf.user.notification.articleComment.response.message.stacked',
38 [
39 'author' => $this->author,
40 'authors' => \array_values($authors),
41 'commentID' => $this->getUserNotificationObject()->commentID,
42 'article' => ViewableArticleContentRuntimeCache::getInstance()
43 ->getObject($this->additionalData['objectID']),
44 'count' => $count,
45 'others' => $count - 1,
46 'guestTimesTriggered' => $this->notification->guestTimesTriggered,
47 'responseID' => $this->getUserNotificationObject()->responseID,
48 ]
49 );
50 }
51
52 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.message', [
53 'author' => $this->author,
54 'commentID' => $this->getUserNotificationObject()->commentID,
55 'article' => ViewableArticleContentRuntimeCache::getInstance()
56 ->getObject($this->additionalData['objectID']),
57 'responseID' => $this->getUserNotificationObject()->responseID,
58 ]);
59 }
60
61 /**
62 * @inheritDoc
63 */
64 public function getEmailMessage($notificationType = 'instant')
65 {
66 $messageID = '<com.woltlab.wcf.user.articleComment.notification/' . $this->getUserNotificationObject()->commentID . '@' . Email::getHost() . '>';
67
68 return [
69 'template' => 'email_notification_commentResponse',
70 'in-reply-to' => [$messageID],
71 'references' => [$messageID],
72 'application' => 'wcf',
73 'variables' => [
74 'commentID' => $this->getUserNotificationObject()->commentID,
75 'article' => ViewableArticleContentRuntimeCache::getInstance()
76 ->getObject($this->additionalData['objectID']),
77 'languageVariablePrefix' => 'wcf.user.notification.articleComment.response',
78 'responseID' => $this->getUserNotificationObject()->responseID,
79 ],
80 ];
81 }
82
83 /**
84 * @inheritDoc
85 */
86 public function getLink(): string
87 {
88 return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getUserNotificationObject()->commentID . '/response' . $this->getUserNotificationObject()->responseID;
89 }
90
91 /**
92 * @inheritDoc
93 */
94 protected function getTypeName(): string
95 {
96 return $this->getLanguage()->get('wcf.user.recentActivity.com.woltlab.wcf.article.recentActivityEvent');
97 }
98
99 /**
100 * @inheritDoc
101 */
102 protected function getObjectTitle(): string
103 {
104 return ViewableArticleContentRuntimeCache::getInstance()
105 ->getObject($this->additionalData['objectID'])->getTitle();
106 }
107 }