6f411613b4919643ca59661433f4b179dc8c7237
[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 response 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 UserProfileCommentResponseLikeUserNotificationEvent 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 UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']);
27 }
28
29 /**
30 * @inheritDoc
31 */
32 public function getTitle() {
33 $count = count($this->getAuthors());
34 if ($count > 1) {
35 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', [
36 'count' => $count,
37 'timesTriggered' => $this->notification->timesTriggered
38 ]);
39 }
40
41 return $this->getLanguage()->get('wcf.user.notification.commentResponse.like.title');
42 }
43
44 /**
45 * @inheritDoc
46 */
47 public function getMessage() {
48 $authors = array_values($this->getAuthors());
49 $count = count($authors);
50 $commentUser = $owner = null;
51 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
52 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
53 }
54 if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
55 $commentUser = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']);
56 }
57
58 if ($count > 1) {
59 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', [
60 'author' => $this->author,
61 'authors' => $authors,
62 'commentUser' => $commentUser,
63 'count' => $count,
64 'others' => $count - 1,
65 'owner' => $owner
66 ]);
67 }
68
69 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', [
70 'author' => $this->author,
71 'owner' => $owner
72 ]);
73 }
74
75 /**
76 * @inheritDoc
77 */
78 public function getEmailMessage($notificationType = 'instant') {
79 throw new \LogicException('Unreachable');
80 }
81
82 /**
83 * @inheritDoc
84 */
85 public function getLink() {
86 $owner = WCF::getUser();
87 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
88 $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
89 }
90
91 return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall');
92 }
93
94 /**
95 * @inheritDoc
96 */
97 public function getEventHash() {
98 return sha1($this->eventID . '-' . $this->additionalData['commentID']);
99 }
100
101 /**
102 * @inheritDoc
103 */
104 public function supportsEmailNotification() {
105 return false;
106 }
107 }