b024727c1cb47dd882f649822983f4ebb817db2a
[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 use wcf\system\WCF;
8
9 /**
10 * User notification event for profile's owner for commment responses.
11 *
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
18 */
19 class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractUserNotificationEvent {
20 /**
21 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
22 */
23 protected $stackable = true;
24
25 /**
26 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
27 */
28 public function getTitle() {
29 $count = count($this->getAuthors());
30 if ($count > 1) {
31 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array(
32 'count' => $count,
33 'timesTriggered' => $this->timesTriggered
34 ));
35 }
36
37 return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
38 }
39
40 /**
41 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
42 */
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);
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.commentResponseOwner.message.stacked', array(
59 'authors' => $authors,
60 'count' => $count,
61 'others' => max($count - 1, 0)
62 ));
63 }
64
65 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
66 'author' => $this->author,
67 'commentAuthor' => $commentAuthor
68 ));
69 }
70
71 /**
72 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
73 */
74 public function getEmailMessage($notificationType = 'instant') {
75 $comment = new Comment($this->userNotificationObject->commentID);
76 $owner = new User($comment->objectID);
77 if ($comment->userID) {
78 $commentAuthor = new User($comment->userID);
79 }
80 else {
81 $commentAuthor = new User(null, array(
82 'username' => $comment->username
83 ));
84 }
85
86 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array(
87 'response' => $this->userNotificationObject,
88 'author' => $this->author,
89 'commentAuthor' => $commentAuthor,
90 'owner' => $owner,
91 'notificationType' => $notificationType
92 ));
93 }
94
95 /**
96 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
97 */
98 public function getLink() {
99 return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
100 }
101
102 /**
103 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
104 */
105 public function getEventHash() {
106 return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
107 }
108 }