Merge branch '2.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / user / notification / event / UserProfileCommentResponseOwnerUserNotificationEvent.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 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-2014 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 AbstractUserNotificationEvent {
20 /**
21 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
22 */
23 public function getTitle() {
24 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
25 }
26
27 /**
28 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
29 */
30 public function getMessage() {
31 // @todo: use cache or a single query to retrieve required data
32 $comment = new Comment($this->userNotificationObject->commentID);
33 if ($comment->userID) {
34 $commentAuthor = new User($comment->userID);
35 }
36 else {
37 $commentAuthor = new User(null, array(
38 'username' => $comment->username
39 ));
40 }
41
42 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
43 'author' => $this->author,
44 'commentAuthor' => $commentAuthor
45 ));
46 }
47
48 /**
49 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
50 */
51 public function getEmailMessage($notificationType = 'instant') {
52 $comment = new Comment($this->userNotificationObject->commentID);
53 $owner = new User($comment->objectID);
54 if ($comment->userID) {
55 $commentAuthor = new User($comment->userID);
56 }
57 else {
58 $commentAuthor = new User(null, array(
59 'username' => $comment->username
60 ));
61 }
62
63 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array(
64 'response' => $this->userNotificationObject,
65 'author' => $this->author,
66 'commentAuthor' => $commentAuthor,
67 'owner' => $owner,
68 'notificationType' => $notificationType
69 ));
70 }
71
72 /**
73 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
74 */
75 public function getLink() {
76 return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
77 }
78 }