5be55669c2189e2dca6eb4cdd6622d01a6e23f8c
[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 $authors = $this->getAuthors();
76 if (count($authors) > 1) {
77 if (isset($authors[0])) {
78 unset($authors[0]);
79 }
80 $count = count($authors);
81
82 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', [
83 'author' => $this->author,
84 'authors' => array_values($authors),
85 'count' => $count,
86 'notificationType' => $notificationType,
87 'others' => $count - 1,
88 'owner' => $owner,
89 'response' => $this->userNotificationObject,
90 'guestTimesTriggered' => $this->notification->guestTimesTriggered
91 ]);
92 }
93
94 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', [
95 'response' => $this->userNotificationObject,
96 'author' => $this->author,
97 'owner' => $owner,
98 'notificationType' => $notificationType
99 ]);
100 }
101
102 /**
103 * @inheritDoc
104 */
105 public function getLink() {
106 return UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#wall';
107 }
108
109 /**
110 * @inheritDoc
111 */
112 public function getEventHash() {
113 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
114 }
115 }