c3f2c4b0e0715224ac2ae8d2887abcaa12aba962
[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\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\AbstractUserNotificationEvent::$stackable
21 */
22 protected $stackable = true;
23
24 /**
25 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
26 */
27 public function getTitle() {
28 $count = count($this->getAuthors());
29 if ($count > 1) {
30 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', array(
31 'count' => $count,
32 'timesTriggered' => $this->timesTriggered
33 ));
34 }
35
36 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
37 }
38
39 /**
40 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
41 */
42 public function getMessage() {
43 // @todo: use cache or a single query to retrieve required data
44 $comment = new Comment($this->userNotificationObject->commentID);
45 $owner = new User($comment->objectID);
46 if ($comment->userID) {
47 $commentAuthor = new User($comment->userID);
48 }
49 else {
50 $commentAuthor = new User(null, array(
51 'username' => $comment->username
52 ));
53 }
54
55 $authors = array_values($this->getAuthors());
56 $count = count($authors);
57 if ($count > 1) {
58 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', array(
59 'authors' => $authors,
60 'count' => $count,
61 'others' => $count - 1,
62 'owner' => $owner
63 ));
64 }
65
66 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.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') {
76 $comment = new Comment($this->userNotificationObject->commentID);
77 $user = new User($comment->objectID);
78
79 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array(
80 'response' => $this->userNotificationObject,
81 'author' => $this->author,
82 'owner' => $user,
83 'notificationType' => $notificationType
84 ));
85 }
86
87 /**
88 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
89 */
90 public function getLink() {
91 // @todo: use cache or a single query to retrieve required data
92 $comment = new Comment($this->userNotificationObject->commentID);
93 $user = new User($comment->objectID);
94
95 return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall');
96 }
97
98 /**
99 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
100 */
101 public function getEventHash() {
102 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
103 }
104 }