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