03c5aad3e49b617921967550e0ea5b20c5725568
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\User;
4 use wcf\system\comment\CommentDataHandler;
5 use wcf\system\request\LinkHandler;
6
7 /**
8 * User notification event for profile commment responses.
9 *
10 * @author Alexander Ebert
11 * @copyright 2001-2014 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage system.user.notification.event
15 * @category Community Framework
16 */
17 class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent {
18 /**
19 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
20 */
21 protected $stackable = true;
22
23 /**
24 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
25 */
26 protected function prepare() {
27 CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
28 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']);
29 CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
30 }
31
32 /**
33 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
34 */
35 public function getTitle() {
36 $count = count($this->getAuthors());
37 if ($count > 1) {
38 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', array(
39 'count' => $count,
40 'timesTriggered' => $this->timesTriggered
41 ));
42 }
43
44 return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
45 }
46
47 /**
48 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
49 */
50 public function getMessage() {
51 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
52 $owner = CommentDataHandler::getInstance()->getUser($comment->objectID);
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 = array_values($this->getAuthors());
63 $count = count($authors);
64 if ($count > 1) {
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', array(
66 'authors' => $authors,
67 'count' => $count,
68 'others' => $count - 1,
69 'owner' => $owner
70 ));
71 }
72
73 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array(
74 'author' => $this->author,
75 'owner' => $owner
76 ));
77 }
78
79 /**
80 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
81 */
82 public function getEmailMessage($notificationType = 'instant') {
83 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
84 $user = new User($comment->objectID);
85
86 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array(
87 'response' => $this->userNotificationObject,
88 'author' => $this->author,
89 'owner' => $user,
90 'notificationType' => $notificationType
91 ));
92 }
93
94 /**
95 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
96 */
97 public function getLink() {
98 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
99 $user = CommentDataHandler::getInstance()->getUser($comment->objectID);
100
101 return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall');
102 }
103
104 /**
105 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
106 */
107 public function getEventHash() {
108 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
109 }
110 }