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;
10 * User notification event for profile's owner for commment responses.
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
19 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractUserNotificationEvent {
21 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
23 protected $stackable = true;
26 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
28 public function getTitle() {
29 $count = count($this->getAuthors());
31 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array(
33 'timesTriggered' => $this->timesTriggered
37 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
41 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
43 public function getMessage() {
44 // @todo: use cache or a single query to retrieve required data
45 $comment = new Comment($this->userNotificationObject->commentID);
46 if ($comment->userID) {
47 $commentAuthor = new User($comment->userID);
50 $commentAuthor = new User(null, array(
51 'username' => $comment->username
55 $authors = array_values($this->getAuthors());
56 $count = count($authors);
58 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array(
59 'author' => $commentAuthor,
60 'authors' => $authors,
62 'others' => max($count - 1, 0)
66 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
67 'author' => $this->author,
68 'commentAuthor' => $commentAuthor
73 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
75 public function getEmailMessage($notificationType = 'instant') {
76 $comment = new Comment($this->userNotificationObject->commentID);
77 $owner = new User($comment->objectID);
78 if ($comment->userID) {
79 $commentAuthor = new User($comment->userID);
82 $commentAuthor = new User(null, array(
83 'username' => $comment->username
87 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array(
88 'response' => $this->userNotificationObject,
89 'author' => $this->author,
90 'commentAuthor' => $commentAuthor,
92 'notificationType' => $notificationType
97 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
99 public function getLink() {
100 return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
104 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
106 public function getEventHash() {
107 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);