1ed3ec7db493b414cc2bb81ac8a822e2ad925213
[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\email\Email;
6 use wcf\system\user\notification\object\CommentResponseUserNotificationObject;
7
8 /**
9 * User notification event for profile comment responses.
10 *
11 * @author Alexander Ebert
12 * @copyright 2001-2016 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package WoltLabSuite\Core\System\User\Notification\Event
15 *
16 * @method CommentResponseUserNotificationObject getUserNotificationObject()
17 */
18 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent {
19 /**
20 * @inheritDoc
21 */
22 protected $stackable = true;
23
24 /**
25 * @inheritDoc
26 */
27 protected function prepare() {
28 CommentRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->commentID);
29 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
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 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
52
53 $authors = $this->getAuthors();
54 if (count($authors) > 1) {
55 if (isset($authors[0])) {
56 unset($authors[0]);
57 }
58 $count = count($authors);
59
60 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
61 'authors' => array_values($authors),
62 'count' => $count,
63 'others' => $count - 1,
64 'owner' => $owner,
65 'guestTimesTriggered' => $this->notification->guestTimesTriggered
66 ]);
67 }
68
69 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
70 'author' => $this->author,
71 'owner' => $owner
72 ]);
73 }
74
75 /**
76 * @inheritDoc
77 */
78 public function getEmailMessage($notificationType = 'instant') {
79 $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
80 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
81
82 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
83
84 return [
85 'template' => 'email_notification_userProfileCommentResponse',
86 'application' => 'wcf',
87 'in-reply-to' => [$messageID],
88 'references' => [$messageID],
89 'variables' => [
90 'owner' => $owner
91 ]
92 ];
93 }
94
95 /**
96 * @inheritDoc
97 */
98 public function getLink() {
99 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall';
100 }
101
102 /**
103 * @inheritDoc
104 */
105 public function getEventHash() {
106 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->commentID);
107 }
108 }