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