52cfecfe0e37e471a7ed17e7e334d1e629c525ec
[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 use wcf\system\user\notification\object\CommentUserNotificationObject;
6
7 /**
8 * User notification event for profile comments.
9 *
10 * @author Alexander Ebert
11 * @copyright 2001-2016 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\User\Notification\Event
14 *
15 * @method CommentUserNotificationObject getUserNotificationObject()
16 */
17 class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotificationEvent {
18 /**
19 * @inheritDoc
20 */
21 protected $stackable = true;
22
23 /**
24 * @inheritDoc
25 */
26 protected function prepare() {
27 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->getUserNotificationObject()->objectID);
28 }
29
30 /**
31 * @inheritDoc
32 */
33 public function getTitle() {
34 $count = count($this->getAuthors());
35 if ($count > 1) {
36 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', [
37 'count' => $count,
38 'timesTriggered' => $this->notification->timesTriggered
39 ]);
40 }
41
42 return $this->getLanguage()->get('wcf.user.notification.comment.title');
43 }
44
45 /**
46 * @inheritDoc
47 */
48 public function getMessage() {
49 $authors = $this->getAuthors();
50 if (count($authors) > 1) {
51 if (isset($authors[0])) {
52 unset($authors[0]);
53 }
54 $count = count($authors);
55
56 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', [
57 'author' => $this->author,
58 'authors' => array_values($authors),
59 'count' => $count,
60 'others' => $count - 1,
61 'guestTimesTriggered' => $this->notification->guestTimesTriggered
62 ]);
63 }
64
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', [
66 'author' => $this->author
67 ]);
68 }
69
70 /**
71 * @inheritDoc
72 */
73 public function getEmailMessage($notificationType = 'instant') {
74 $user = UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID);
75
76 $authors = $this->getAuthors();
77 if (count($authors) > 1) {
78 if (isset($authors[0])) {
79 unset($authors[0]);
80 }
81 $count = count($authors);
82
83 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', [
84 'author' => $this->author,
85 'authors' => array_values($authors),
86 'count' => $count,
87 'others' => $count - 1,
88 'owner' => $user,
89 'notificationType' => $notificationType,
90 'guestTimesTriggered' => $this->notification->guestTimesTriggered
91 ]);
92 }
93
94 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', [
95 'comment' => $this->userNotificationObject,
96 'author' => $this->author,
97 'owner' => $user,
98 'notificationType' => $notificationType
99 ]);
100 }
101
102 /**
103 * @inheritDoc
104 */
105 public function getLink() {
106 return LinkHandler::getInstance()->getLink('User', ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)], '#wall');
107 }
108
109 /**
110 * @inheritDoc
111 */
112 public function getEventHash() {
113 return sha1($this->eventID . '-' . $this->notification->userID);
114 }
115 }