mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2025-01-09 00:20:08 +00:00
Adding ChatMessagePage
This commit is contained in:
parent
bdb7ec3b0d
commit
d2670d47c3
@ -132,6 +132,12 @@ TimWolla.WCF ?= {}
|
|||||||
# Loads new messages.
|
# Loads new messages.
|
||||||
###
|
###
|
||||||
getMessages: () ->
|
getMessages: () ->
|
||||||
|
$.ajax 'index.php/Chat/Message/',
|
||||||
|
dataType: 'json'
|
||||||
|
type: 'POST'
|
||||||
|
success: $.proxy((data, textStatus, jqXHR) ->
|
||||||
|
@handleMessages(data)
|
||||||
|
, this)
|
||||||
###
|
###
|
||||||
# Inserts the new messages.
|
# Inserts the new messages.
|
||||||
#
|
#
|
||||||
|
56
file/lib/page/ChatMessagePage.class.php
Normal file
56
file/lib/page/ChatMessagePage.class.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
namespace wcf\page;
|
||||||
|
use \wcf\data\chat;
|
||||||
|
use \wcf\system\WCF;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads new messages.
|
||||||
|
*
|
||||||
|
* @author Tim Düsterhus
|
||||||
|
* @copyright 2010-2011 Tim Düsterhus
|
||||||
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
|
* @package timwolla.wcf.chat
|
||||||
|
* @subpackage page
|
||||||
|
*/
|
||||||
|
class ChatMessagePage extends AbstractPage {
|
||||||
|
public $messages = array();
|
||||||
|
public $neededModules = array('CHAT_ACTIVE');
|
||||||
|
//public $neededPermissions = array('user.chat.canEnter');
|
||||||
|
public $room = null;
|
||||||
|
public $roomID = 0;
|
||||||
|
public $useTemplate = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads room data.
|
||||||
|
*/
|
||||||
|
public function readData() {
|
||||||
|
parent::readData();
|
||||||
|
$this->roomID = \wcf\util\ChatUtil::readUserData('roomID');
|
||||||
|
|
||||||
|
$this->room = chat\room\ChatRoom::getCache()->search($this->roomID);
|
||||||
|
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
|
||||||
|
|
||||||
|
$this->messages = chat\message\ChatMessageList::getMessagesSince($this->room, \wcf\util\ChatUtil::readUserData('lastSeen'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\IPage::show()
|
||||||
|
*/
|
||||||
|
public function show() {
|
||||||
|
// guests are not supported
|
||||||
|
if (!WCF::getUser()->userID) {
|
||||||
|
throw new \wcf\system\exception\PermissionDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::show();
|
||||||
|
|
||||||
|
@header('Content-type: application/json');
|
||||||
|
$result = '[';
|
||||||
|
foreach ($this->messages as $message) {
|
||||||
|
$result .= $message->jsonify().',';
|
||||||
|
}
|
||||||
|
echo rtrim($result, ',').']';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
@ -106,7 +106,11 @@ public function readDefaultSmileys() {
|
|||||||
public function readParameters() {
|
public function readParameters() {
|
||||||
parent::readParameters();
|
parent::readParameters();
|
||||||
|
|
||||||
if ($this->action == 'Log') {
|
if ($this->action == 'Message') {
|
||||||
|
new ChatMessagePage();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else if ($this->action == 'Log') {
|
||||||
//TODO: Initialise LogPage
|
//TODO: Initialise LogPage
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public function execute($eventObj, $className, $eventName) {
|
|||||||
$route = new \wcf\system\request\Route('chatAction');
|
$route = new \wcf\system\request\Route('chatAction');
|
||||||
$route->setSchema('/{controller}/{action}');
|
$route->setSchema('/{controller}/{action}');
|
||||||
$route->setParameterOption('controller', null, 'Chat');
|
$route->setParameterOption('controller', null, 'Chat');
|
||||||
$route->setParameterOption('action', null, '(Log|Send|RefreshRoomList)');
|
$route->setParameterOption('action', null, '(Message|Log|Send|RefreshRoomList)');
|
||||||
$eventObj->addRoute($route);
|
$eventObj->addRoute($route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user