649b21e8c6c3f34ae35ce94fb104f2dad97ef2f9
[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 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 UserProfileCommentLikeUserNotificationEvent 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 }
29
30 /**
31 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
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', array(
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 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
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 = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
54 }
55
56 if ($count > 1) {
57 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', array(
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', array(
67 'author' => $this->author,
68 'owner' => $owner
69 ));
70 }
71
72 /**
73 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
74 */
75 public function getEmailMessage($notificationType = 'instant') { /* not supported */ }
76
77 /**
78 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
79 */
80 public function getLink() {
81 $owner = WCF::getUser();
82 if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
83 $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
84 }
85
86 return LinkHandler::getInstance()->getLink('User', array(
87 'object' => $owner
88 ), '#wall');
89 }
90
91 /**
92 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
93 */
94 public function getEventHash() {
95 return sha1($this->eventID . '-' . $this->additionalData['objectID']);
96 }
97
98 /**
99 * @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification()
100 */
101 public function supportsEmailNotification() {
102 return false;
103 }
104 }