e25d587a32af399cafa8c2312d39fd0aa270e137
[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
54 $authors = array_values($this->getAuthors());
55 $count = count($authors);
56 if ($count > 1) {
57 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', array(
58 'authors' => $authors,
59 'count' => $count,
60 'others' => $count - 1,
61 'owner' => $owner
62 ));
63 }
64
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array(
66 'author' => $this->author,
67 'owner' => $owner
68 ));
69 }
70
71 /**
72 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
73 */
74 public function getEmailMessage($notificationType = 'instant') {
75 $authors = array_values($this->getAuthors());
76 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
77 $count = count($authors);
78 $owner = CommentDataHandler::getInstance()->getUser($comment->objectID);
79
80 if ($count > 1) {
81 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', array(
82 'author' => $this->author,
83 'authors' => $authors,
84 'count' => $count,
85 'notificationType' => $notificationType,
86 'others' => $count - 1,
87 'owner' => $owner,
88 'response' => $this->userNotificationObject
89 ));
90 }
91
92 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array(
93 'response' => $this->userNotificationObject,
94 'author' => $this->author,
95 'owner' => $owner,
96 'notificationType' => $notificationType
97 ));
98 }
99
100 /**
101 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
102 */
103 public function getLink() {
104 $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
105 $user = CommentDataHandler::getInstance()->getUser($comment->objectID);
106
107 return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall');
108 }
109
110 /**
111 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
112 */
113 public function getEventHash() {
114 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
115 }
116 }