ac7ea1e4b60dd4fc8a12a9d50d8202cff98c0da7
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\system\cache\runtime\UserProfileRuntimeCache;
4 use wcf\system\email\Email;
5
6 /**
7 * User notification event for profile comment responses.
8 *
9 * @author Alexander Ebert
10 * @copyright 2001-2016 WoltLab GmbH
11 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
12 * @package WoltLabSuite\Core\System\User\Notification\Event
13 */
14 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent {
15 /**
16 * @inheritDoc
17 */
18 protected $stackable = true;
19
20 /**
21 * @inheritDoc
22 */
23 protected function prepare() {
24 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
25 }
26
27 /**
28 * @inheritDoc
29 */
30 public function getTitle() {
31 $count = count($this->getAuthors());
32 if ($count > 1) {
33 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [
34 'count' => $count,
35 'timesTriggered' => $this->notification->timesTriggered
36 ]);
37 }
38
39 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
40 }
41
42 /**
43 * @inheritDoc
44 */
45 public function getMessage() {
46 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
47
48 $authors = $this->getAuthors();
49 if (count($authors) > 1) {
50 if (isset($authors[0])) {
51 unset($authors[0]);
52 }
53 $count = count($authors);
54
55 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
56 'authors' => array_values($authors),
57 'count' => $count,
58 'others' => $count - 1,
59 'owner' => $owner,
60 'guestTimesTriggered' => $this->notification->guestTimesTriggered
61 ]);
62 }
63
64 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
65 'author' => $this->author,
66 'owner' => $owner
67 ]);
68 }
69
70 /**
71 * @inheritDoc
72 */
73 public function getEmailMessage($notificationType = 'instant') {
74 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
75
76 $messageID = '<com.woltlab.wcf.user.profileComment.notification/'.$comment->commentID.'@'.Email::getHost().'>';
77
78 return [
79 'template' => 'email_notification_userProfileCommentResponse',
80 'application' => 'wcf',
81 'in-reply-to' => [$messageID],
82 'references' => [$messageID],
83 'variables' => [
84 'owner' => $owner
85 ]
86 ];
87 }
88
89 /**
90 * @inheritDoc
91 */
92 public function getLink() {
93 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall';
94 }
95
96 /**
97 * @inheritDoc
98 */
99 public function getEventHash() {
100 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
101 }
102 }