ad15f67d366855eb1c047ebc7bf62c05d6f1b406
[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 'template' => 'email_notification_userProfileComment',
77 'application' => 'wcf',
78 'variables' => [
79 'owner' => new User($this->getUserNotificationObject()->objectID)
80 ]
81 ];
82 }
83
84 /**
85 * @inheritDoc
86 */
87 public function getLink() {
88 return LinkHandler::getInstance()->getLink('User', ['object' => UserProfileRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->objectID)], '#wall');
89 }
90
91 /**
92 * @inheritDoc
93 */
94 public function getEventHash() {
95 return sha1($this->eventID . '-' . $this->notification->userID);
96 }
97 }