76c5646e55d4cd5bbe4825557a388c651b8b4ec9
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\User;
4 use wcf\system\request\LinkHandler;
5
6 /**
7 * User notification event for profile commments.
8 *
9 * @author Alexander Ebert
10 * @copyright 2001-2015 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 UserProfileCommentUserNotificationEvent extends AbstractUserNotificationEvent {
17 /**
18 * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
19 */
20 protected $stackable = true;
21
22 /**
23 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
24 */
25 public function getTitle() {
26 $count = count($this->getAuthors());
27 if ($count > 1) {
28 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.title.stacked', array(
29 'count' => $count,
30 'timesTriggered' => $this->notification->timesTriggered
31 ));
32 }
33
34 return $this->getLanguage()->get('wcf.user.notification.comment.title');
35 }
36
37 /**
38 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
39 */
40 public function getMessage() {
41 $authors = $this->getAuthors();
42 if (count($authors) > 1) {
43 if (isset($authors[0])) {
44 unset($authors[0]);
45 }
46 $count = count($authors);
47
48 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message.stacked', array(
49 'author' => $this->author,
50 'authors' => array_values($authors),
51 'count' => $count,
52 'others' => $count - 1,
53 'guestTimesTriggered' => $this->notification->guestTimesTriggered
54 ));
55 }
56
57 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.message', array(
58 'author' => $this->author
59 ));
60 }
61
62 /**
63 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
64 */
65 public function getEmailMessage($notificationType = 'instant') {
66 $user = new User($this->userNotificationObject->objectID);
67
68 $authors = $this->getAuthors();
69 if (count($authors) > 1) {
70 if (isset($authors[0])) {
71 unset($authors[0]);
72 }
73 $count = count($authors);
74
75 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail.stacked', array(
76 'author' => $this->author,
77 'authors' => array_values($authors),
78 'count' => $count,
79 'others' => $count - 1,
80 'owner' => $user,
81 'notificationType' => $notificationType,
82 'guestTimesTriggered' => $this->notification->guestTimesTriggered
83 ));
84 }
85
86 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.mail', array(
87 'comment' => $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 return LinkHandler::getInstance()->getLink('User', array('id' => $this->userNotificationObject->objectID), '#wall');
99 }
100
101 /**
102 * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
103 */
104 public function getEventHash() {
105 return sha1($this->eventID . '-' . $this->notification->userID);
106 }
107 }