aa25716ddbe9c2dc4d82eec2cf31b4fd3832631e
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\system\comment\CommentDataHandler;
4 use wcf\system\request\LinkHandler;
5 use wcf\system\WCF;
6
7 /**
8 * User notification event for profile commment response likes.
9 *
10 * @author Alexander Ebert
11 * @copyright 2001-2015 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 UserProfileCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent {
18 /**
19 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
20 */
21 protected $stackable = true;
22
23 /**
24 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
25 */
26 protected function prepare() {
27 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']);
28 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['commentUserID']);
29 }
30
31 /**
32 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
33 */
34 public function getTitle() {
35 $count = count($this->getAuthors());
36 if ($count > 1) {
37 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', array(
38 'count' => $count,
39 'timesTriggered' => $this->notification->timesTriggered
40 ));
41 }
42
43 return $this->getLanguage()->get('wcf.user.notification.commentResponse.like.title');
44 }
45
46 /**
47 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
48 */
49 public function getMessage() {
50 $authors = array_values($this->getAuthors());
51 $count = count($authors);
52 $commentUser = $owner = null;
53 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
54 $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
55 }
56 if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
57 $commentUser = CommentDataHandler::getInstance()->getUser($this->additionalData['commentUserID']);
58 }
59
60 if ($count > 1) {
61 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', array(
62 'author' => $this->author,
63 'authors' => $authors,
64 'commentUser' => $commentUser,
65 'count' => $count,
66 'others' => $count - 1,
67 'owner' => $owner
68 ));
69 }
70
71 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', array(
72 'author' => $this->author,
73 'owner' => $owner
74 ));
75 }
76
77 /**
78 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
79 */
80 public function getEmailMessage($notificationType = 'instant') { /* not supported */ }
81
82 /**
83 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
84 */
85 public function getLink() {
86 $owner = WCF::getUser();
87 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
88 $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
89 }
90
91 return LinkHandler::getInstance()->getLink('User', array(
92 'object' => $owner
93 ), '#wall');
94 }
95
96 /**
97 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
98 */
99 public function getEventHash() {
100 return sha1($this->eventID . '-' . $this->additionalData['commentID']);
101 }
102
103 /**
104 * @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification()
105 */
106 public function supportsEmailNotification() {
107 return false;
108 }
109 }