2f631d54c41a1cf5a19494ee76aea57e3a260b8f
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\system\cache\runtime\UserProfileRuntimeCache;
4 use wcf\system\request\LinkHandler;
5
6 /**
7 * User notification event for profile comments.
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 UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent {
15 /**
16 * @inheritDoc
17 */
18 protected $stackable = true;
19
20 /**
21 * @inheritDoc
22 */
23 protected function prepare() {
24 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->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.comment.title.stacked', [
34 'count' => $count,
35 'timesTriggered' => $this->notification->timesTriggered
36 ]);
37 }
38
39 return $this->getLanguage()->get('wcf.user.notification.comment.title');
40 }
41
42 /**
43 * @inheritDoc
44 */
45 public function getMessage() {
46 $authors = $this->getAuthors();
47 if (count($authors) > 1) {
48 if (isset($authors[0])) {
49 unset($authors[0]);
50 }
51 $count = count($authors);
52
53 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', [
54 'author' => $this->author,
55 'authors' => array_values($authors),
56 'count' => $count,
57 'others' => $count - 1,
58 'guestTimesTriggered' => $this->notification->guestTimesTriggered
59 ]);
60 }
61
62 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', [
63 'author' => $this->author
64 ]);
65 }
66
67 /**
68 * @inheritDoc
69 */
70 public function getEmailMessage($notificationType = 'instant') {
71 $user = UserProfileRuntimeCache::getInstance()->getObject($this->userNotificationObject->objectID);
72
73 $authors = $this->getAuthors();
74 if (count($authors) > 1) {
75 if (isset($authors[0])) {
76 unset($authors[0]);
77 }
78 $count = count($authors);
79
80 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', [
81 'author' => $this->author,
82 'authors' => array_values($authors),
83 'count' => $count,
84 'others' => $count - 1,
85 'owner' => $user,
86 'notificationType' => $notificationType,
87 'guestTimesTriggered' => $this->notification->guestTimesTriggered
88 ]);
89 }
90
91 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', [
92 'comment' => $this->userNotificationObject,
93 'author' => $this->author,
94 'owner' => $user,
95 'notificationType' => $notificationType
96 ]);
97 }
98
99 /**
100 * @inheritDoc
101 */
102 public function getLink() {
103 return LinkHandler::getInstance()->getLink('User', ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->userNotificationObject->objectID)], '#wall');
104 }
105
106 /**
107 * @inheritDoc
108 */
109 public function getEventHash() {
110 return sha1($this->eventID . '-' . $this->notification->userID);
111 }
112 }