1a60438544815852361fd352a66d415baec75f5f
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\system\cache\runtime\CommentRuntimeCache;
4 use wcf\system\cache\runtime\UserProfileRuntimeCache;
5 use wcf\system\request\LinkHandler;
6
7 /**
8 * User notification event for profile commment responses.
9 *
10 * @author Alexander Ebert
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.user.notification.event
15 * @category Community Framework
16 */
17 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent {
18 /**
19 * @inheritDoc
20 */
21 protected $stackable = true;
22
23 /**
24 * @inheritDoc
25 */
26 protected function prepare() {
27 CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID);
28 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
29 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
30 }
31
32 /**
33 * @inheritDoc
34 */
35 public function getTitle() {
36 $count = count($this->getAuthors());
37 if ($count > 1) {
38 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [
39 'count' => $count,
40 'timesTriggered' => $this->notification->timesTriggered
41 ]);
42 }
43
44 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
45 }
46
47 /**
48 * @inheritDoc
49 */
50 public function getMessage() {
51 $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
52 $owner = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID);
53
54 $authors = $this->getAuthors();
55 if (count($authors) > 1) {
56 if (isset($authors[0])) {
57 unset($authors[0]);
58 }
59 $count = count($authors);
60
61 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
62 'authors' => array_values($authors),
63 'count' => $count,
64 'others' => $count - 1,
65 'owner' => $owner,
66 'guestTimesTriggered' => $this->notification->guestTimesTriggered
67 ]);
68 }
69
70 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
71 'author' => $this->author,
72 'owner' => $owner
73 ]);
74 }
75
76 /**
77 * @inheritDoc
78 */
79 public function getEmailMessage($notificationType = 'instant') {
80 $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
81 $owner = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID);
82
83 $authors = $this->getAuthors();
84 if (count($authors) > 1) {
85 if (isset($authors[0])) {
86 unset($authors[0]);
87 }
88 $count = count($authors);
89
90 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', [
91 'author' => $this->author,
92 'authors' => array_values($authors),
93 'count' => $count,
94 'notificationType' => $notificationType,
95 'others' => $count - 1,
96 'owner' => $owner,
97 'response' => $this->userNotificationObject,
98 'guestTimesTriggered' => $this->notification->guestTimesTriggered
99 ]);
100 }
101
102 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', [
103 'response' => $this->userNotificationObject,
104 'author' => $this->author,
105 'owner' => $owner,
106 'notificationType' => $notificationType
107 ]);
108 }
109
110 /**
111 * @inheritDoc
112 */
113 public function getLink() {
114 $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
115 $user = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID);
116
117 return LinkHandler::getInstance()->getLink('User', ['object' => $user], '#wall');
118 }
119
120 /**
121 * @inheritDoc
122 */
123 public function getEventHash() {
124 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
125 }
126 }