2871ee23d1839dec0a40bad67aef8a48a4f0b59d
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\data\comment\Comment;
4 use wcf\data\user\User;
5 use wcf\system\comment\CommentDataHandler;
6 use wcf\system\request\LinkHandler;
7 use wcf\system\WCF;
8
9 /**
10 * User notification event for profile's owner for commment responses.
11 *
12 * @author Alexander Ebert
13 * @copyright 2001-2015 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package com.woltlab.wcf
16 * @subpackage system.user.notification.event
17 * @category Community Framework
18 */
19 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
20 /**
21 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
22 */
23 protected $stackable = true;
24
25 /**
26 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
27 */
28 protected function prepare() {
29 CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
30 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
31 }
32
33 /**
34 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
35 */
36 public function getTitle() {
37 $count = count($this->getAuthors());
38 if ($count > 1) {
39 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array(
40 'count' => $count,
41 'timesTriggered' => $this->notification->timesTriggered
42 ));
43 }
44
45 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
46 }
47
48 /**
49 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
50 */
51 public function getMessage() {
52 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
53 if ($comment->userID) {
54 $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID);
55 }
56 else {
57 $commentAuthor = new User(null, array(
58 'username' => $comment->username
59 ));
60 }
61
62 $authors = $this->getAuthors();
63 if (count($authors) > 1) {
64 if (isset($authors[0])) {
65 unset($authors[0]);
66 }
67 $count = count($authors);
68
69 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array(
70 'author' => $commentAuthor,
71 'authors' => array_values($authors),
72 'count' => $count,
73 'others' => $count - 1,
74 'guestTimesTriggered' => $this->notification->guestTimesTriggered
75 ));
76 }
77
78 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
79 'author' => $this->author,
80 'commentAuthor' => $commentAuthor
81 ));
82 }
83
84 /**
85 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
86 */
87 public function getEmailMessage($notificationType = 'instant') {
88 $comment = new Comment($this->userNotificationObject->commentID);
89 $owner = new User($comment->objectID);
90 if ($comment->userID) {
91 $commentAuthor = new User($comment->userID);
92 }
93 else {
94 $commentAuthor = new User(null, array(
95 'username' => $comment->username
96 ));
97 }
98
99 $authors = $this->getAuthors();
100 if (count($authors) > 1) {
101 if (isset($authors[0])) {
102 unset($authors[0]);
103 }
104 $count = count($authors);
105
106 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', array(
107 'author' => $this->author,
108 'authors' => array_values($authors),
109 'commentAuthor' => $commentAuthor,
110 'count' => $count,
111 'notificationType' => $notificationType,
112 'others' => $count - 1,
113 'owner' => $owner,
114 'response' => $this->userNotificationObject,
115 'guestTimesTriggered' => $this->notification->guestTimesTriggered
116 ));
117 }
118
119 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array(
120 'response' => $this->userNotificationObject,
121 'author' => $this->author,
122 'commentAuthor' => $commentAuthor,
123 'owner' => $owner,
124 'notificationType' => $notificationType
125 ));
126 }
127
128 /**
129 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
130 */
131 public function getLink() {
132 return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
133 }
134
135 /**
136 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
137 */
138 public function getEventHash() {
139 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
140 }
141 }