diff --git a/eventListener.xml b/eventListener.xml
new file mode 100644
index 0000000..612b7d8
--- /dev/null
+++ b/eventListener.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ wcf\system\request\RouteHandler
+ didInit
+ user
+ 0
+ wcf\system\event\listener\ChatRouteListener
+
+
+
\ No newline at end of file
diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php
index 50cb493..6b9e551 100644
--- a/file/lib/page/ChatPage.class.php
+++ b/file/lib/page/ChatPage.class.php
@@ -20,6 +20,7 @@ class ChatPage extends AbstractPage {
public $neededModules = array('CHAT_ACTIVE');
//public $neededPermissions = array('user.chat.canEnter');
public $joinMessage = null;
+ public $newestMessages = array();
public $room = null;
public $roomID = 0;
public $rooms = array();
@@ -35,6 +36,7 @@ public function assignVariables() {
WCF::getTPL()->assign(array(
'chatVersion' => $this->chatVersion,
'joinMessage' => $this->joinMessage,
+ 'newestMessages' => $this->newestMessages,
'room' => $this->room,
'roomID' => $this->roomID,
'rooms' => $this->rooms,
@@ -77,18 +79,11 @@ public function readData() {
'color1' => $this->userData['color'][1],
'color2' => $this->userData['color'][2]
));
- if ($this->room->topic != '') {
- chat\message\ChatMessageEditor::create(array(
- 'roomID' => $this->room->roomID,
- 'sender' => WCF::getUser()->userID,
- 'time' => TIME_NOW,
- 'type' => chat\message\ChatMessage::TYPE_INFORMATION,
- 'message' => WCF::getLanguage()->getDynamicVariable($this->room->topic)
- ));
- }
$this->readDefaultSmileys();
$this->readChatVersion();
+
+ $this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, 5);
}
/**
@@ -105,7 +100,19 @@ public function readDefaultSmileys() {
public function readParameters() {
parent::readParameters();
- if (isset($_GET['id'])) $this->roomID = (int) $_GET['id'];
+ if ($this->action == 'Log') {
+ //TODO: Initialise LogPage
+ exit;
+ }
+ elseif($this->action == 'Send') {
+ //TODO: Safe message in database
+ exit;
+ }
+
+ if (isset($_REQUEST['id'])) $this->roomID = (int) $_REQUEST['id'];
+ if (isset($_REQUEST['ajax'])) {
+ $this->useTemplate = false;
+ }
}
/**
@@ -171,5 +178,12 @@ public function show() {
// remove index breadcrumb
WCF::getBreadcrumbs()->remove(0);
parent::show();
+ if ($this->useTemplate) exit;
+ @header('Content-type: application/json');
+ echo \wcf\util\JSON::encode(array(
+ 'title' => WCF::getLanguage()->get($this->room->title),
+ 'topic' => WCF::getLanguage()->get($this->room->topic)
+ ));
+ exit;
}
}
diff --git a/file/lib/system/event/listener/ChatRouteListener.class.php b/file/lib/system/event/listener/ChatRouteListener.class.php
new file mode 100644
index 0000000..4f67713
--- /dev/null
+++ b/file/lib/system/event/listener/ChatRouteListener.class.php
@@ -0,0 +1,17 @@
+setSchema('/{controller}/{action}');
+ $route->setParameterOption('controller', null, 'Chat');
+ $route->setParameterOption('action', null, '(Log|Send)');
+ $eventObj->addRoute($route);
+ }
+}
\ No newline at end of file
diff --git a/package.xml b/package.xml
index fc26253..15abc57 100644
--- a/package.xml
+++ b/package.xml
@@ -29,6 +29,7 @@
objectType.xml
option.xml
pagemenu.xml
+ eventListener.xml
templatelistener.xml
acloptions.xml
@@ -41,6 +42,7 @@
objectType.xml
option.xml
pagemenu.xml
+ eventListener.xml
templatelistener.xml
acloptions.xml