2 namespace wcf\system\user\notification\event
;
3 use wcf\system\email\Email
;
4 use wcf\system\request\LinkHandler
;
5 use wcf\system\user\notification\
object\ConversationMessageUserNotificationObject
;
8 * User notification event for conversation messages.
11 * @copyright 2001-2017 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\User\Notification\Event
15 * @method ConversationMessageUserNotificationObject getUserNotificationObject()
17 class ConversationMessageUserNotificationEvent
extends AbstractUserNotificationEvent
{
21 protected $stackable = true;
26 public function getTitle() {
27 $count = count($this->getAuthors());
29 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.conversation.message.title.stacked', ['count' => $count]);
32 return $this->getLanguage()->get('wcf.user.notification.conversation.message.title');
38 public function getMessage() {
39 $authors = array_values($this->getAuthors());
40 $count = count($authors);
43 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.conversation.message.message.stacked', [
44 'author' => $this->author
,
45 'authors' => $authors,
47 'message' => $this->userNotificationObject
,
48 'others' => $count - 1
52 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.conversation.message.message', [
53 'author' => $this->author
,
54 'message' => $this->userNotificationObject
58 /** @noinspection PhpMissingParentCallCommonInspection */
62 public function getEmailMessage($notificationType = 'instant') {
63 $messageID = '<com.woltlab.wcf.conversation.notification/'.$this->getUserNotificationObject()->getConversation()->conversationID
.'@'.Email
::getHost().'>';
66 'template' => 'email_notification_conversationMessage',
67 'application' => 'wcf',
68 'in-reply-to' => [$messageID],
69 'references' => [$messageID]
76 public function getLink() {
77 return LinkHandler
::getInstance()->getLink('Conversation', [
78 'object' => $this->getUserNotificationObject()->getConversation(),
79 'messageID' => $this->getUserNotificationObject()->messageID
80 ], '#message'.$this->getUserNotificationObject()->messageID
);
83 /** @noinspection PhpMissingParentCallCommonInspection */
87 public function getEventHash() {
88 return sha1($this->eventID
. '-' . $this->getUserNotificationObject()->conversationID
);
91 /** @noinspection PhpMissingParentCallCommonInspection */
95 public function checkAccess() {
96 return $this->getUserNotificationObject()->getConversation()->canRead();