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