8a7129636d8cc2ea4590f6cbbe7adf7fcbe67173
[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\WCF;
6
7 /**
8 * User notification event for profile commment likes.
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 com.woltlab.wcf
14 * @subpackage system.user.notification.event
15 * @category Community Framework
16 */
17 class UserProfileCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent {
18 /**
19 * @inheritDoc
20 */
21 protected $stackable = true;
22
23 /**
24 * @inheritDoc
25 */
26 protected function prepare() {
27 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['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.like.title.stacked', [
37 'count' => $count,
38 'timesTriggered' => $this->notification->timesTriggered
39 ]);
40 }
41
42 return $this->getLanguage()->get('wcf.user.notification.comment.like.title');
43 }
44
45 /**
46 * @inheritDoc
47 */
48 public function getMessage() {
49 $authors = array_values($this->getAuthors());
50 $count = count($authors);
51 $owner = null;
52 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
53 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
54 }
55
56 if ($count > 1) {
57 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', [
58 'author' => $this->author,
59 'authors' => $authors,
60 'count' => $count,
61 'others' => $count - 1,
62 'owner' => $owner
63 ]);
64 }
65
66 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [
67 'author' => $this->author,
68 'owner' => $owner
69 ]);
70 }
71
72 /**
73 * @inheritDoc
74 */
75 public function getEmailMessage($notificationType = 'instant') {
76 throw new \LogicException('Unreachable');
77 }
78
79 /**
80 * @inheritDoc
81 */
82 public function getLink() {
83 $owner = WCF::getUser();
84 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
85 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
86 }
87
88 return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall');
89 }
90
91 /**
92 * @inheritDoc
93 */
94 public function getEventHash() {
95 return sha1($this->eventID . '-' . $this->additionalData['objectID']);
96 }
97
98 /**
99 * @inheritDoc
100 */
101 public function supportsEmailNotification() {
102 return false;
103 }
104 }