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