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