Merge branch '2.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / user / notification / event / UserProfileCommentResponseUserNotificationEvent.class.php
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\request\LinkHandler;
6 use wcf\system\user\notification\event\AbstractUserNotificationEvent;
7
8 /**
9 * User notification event for profile commment responses.
10 *
11 * @author Alexander Ebert
12 * @copyright 2001-2014 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package com.woltlab.wcf
15 * @subpackage system.user.notification.event
16 * @category Community Framework
17 */
18 class UserProfileCommentResponseUserNotificationEvent extends AbstractUserNotificationEvent {
19 /**
20 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
21 */
22 public function getTitle() {
23 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
24 }
25
26 /**
27 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
28 */
29 public function getMessage() {
30 // @todo: use cache or a single query to retrieve required data
31 $comment = new Comment($this->userNotificationObject->commentID);
32 if ($comment->userID) {
33 $commentAuthor = new User($comment->userID);
34 }
35 else {
36 $commentAuthor = new User(null, array(
37 'username' => $comment->username
38 ));
39 }
40
41 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array(
42 'author' => $this->author,
43 'owner' => $user
44 ));
45 }
46
47 /**
48 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
49 */
50 public function getEmailMessage($notificationType = 'instant') {
51 $comment = new Comment($this->userNotificationObject->commentID);
52 $user = new User($comment->objectID);
53
54 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array(
55 'response' => $this->userNotificationObject,
56 'author' => $this->author,
57 'owner' => $user,
58 'notificationType' => $notificationType
59 ));
60 }
61
62 /**
63 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
64 */
65 public function getLink() {
66 // @todo: use cache or a single query to retrieve required data
67 $comment = new Comment($this->userNotificationObject->commentID);
68 $user = new User($comment->objectID);
69
70 return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall');
71 }
72 }