mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Merge branch 'protocol'
This commit is contained in:
commit
f654c7f2a6
@ -27,7 +27,14 @@
|
|||||||
<controller><![CDATA[chat\acp\page\ChatSuspensionListPage]]></controller>
|
<controller><![CDATA[chat\acp\page\ChatSuspensionListPage]]></controller>
|
||||||
<parent>chat.acp.menu.link.chat</parent>
|
<parent>chat.acp.menu.link.chat</parent>
|
||||||
<permissions>admin.chat.canManageSuspensions</permissions>
|
<permissions>admin.chat.canManageSuspensions</permissions>
|
||||||
<showorder>1</showorder>
|
<showorder>3</showorder>
|
||||||
|
</acpmenuitem>
|
||||||
|
|
||||||
|
<acpmenuitem name="chat.acp.menu.link.log">
|
||||||
|
<controller><![CDATA[chat\acp\page\MessageLogPage]]></controller>
|
||||||
|
<parent>chat.acp.menu.link.chat</parent>
|
||||||
|
<permissions>admin.chat.canReadLog</permissions>
|
||||||
|
<showorder>4</showorder>
|
||||||
</acpmenuitem>
|
</acpmenuitem>
|
||||||
</import>
|
</import>
|
||||||
</data>
|
</data>
|
||||||
|
26
acptemplate/__messageLogTable.tpl
Normal file
26
acptemplate/__messageLogTable.tpl
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{if $messages|count > 0}
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{lang}wcf.global.objectID{/lang}</th>
|
||||||
|
<th>{lang}chat.general.time{/lang}</th>
|
||||||
|
<th colspan="2">{lang}wcf.user.username{/lang}</th>
|
||||||
|
<th>{lang}chat.acp.log.message{/lang}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{foreach from=$messages item="message"}
|
||||||
|
<tr>
|
||||||
|
<td class="columnID">{$message->messageID}</td>
|
||||||
|
<td style="width: 1px !important;">{$message->time|date:"H:i:s"}</td>
|
||||||
|
<td class="columnIcon"><p class="framed">{@$message->getUserProfile()->getAvatar()->getImageTag(24)}</p></td>
|
||||||
|
<td class="columnTitle columnUsername right" style="width: 1px !important;">{$message->username}</td>
|
||||||
|
<td>{@$message->getFormattedMessage("text/simplified-html")}</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{else}
|
||||||
|
<p class="info">{lang}wcf.global.noItems{/lang}</p>
|
||||||
|
{/if}
|
108
acptemplate/messageLog.tpl
Normal file
108
acptemplate/messageLog.tpl
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
{include file='header' pageTitle='chat.acp.log.title'}
|
||||||
|
|
||||||
|
<script data-relocate="true" src="{$__wcf->getPath('chat')}acp/js/be.bastelstu.Chat.ACP.Log{if !ENABLE_DEBUG_MODE}.min{/if}.js?version={PACKAGE_VERSION|rawurlencode}"></script>
|
||||||
|
|
||||||
|
{if $errorField === ''}
|
||||||
|
<script data-relocate="true">
|
||||||
|
//<![CDATA[
|
||||||
|
$(function() {
|
||||||
|
be.bastelstu.Chat.ACP.Log.TabMenu.init();
|
||||||
|
WCF.TabMenu.init();
|
||||||
|
});
|
||||||
|
//]]>
|
||||||
|
</script>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
|
<header class="boxHeadline">
|
||||||
|
<h1>{lang}{@$pageTitle}{/lang}</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<form method="post" action="{link controller='MessageLog' application='chat'}{/link}">
|
||||||
|
<div class="container containerPadding marginTop">
|
||||||
|
<fieldset>
|
||||||
|
<legend>{lang}wcf.global.filter{/lang}</legend>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt><label for="id">{lang}chat.general.room{/lang}</label></dt>
|
||||||
|
<dd>
|
||||||
|
<select id="id" name="id">
|
||||||
|
{foreach from=$rooms item='roomBit'}
|
||||||
|
<option value="{$roomBit->roomID}"{if $roomBit->roomID == $room->roomID} selected="selected"{/if}>{$roomBit}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<dl{if $errorField == 'date'} class="formError"{/if}>
|
||||||
|
<dt><label for="date">{lang}chat.general.time{/lang}</label></dt>
|
||||||
|
<dd>
|
||||||
|
<input id="date" type="date" name="date" value="{$date|date:'Y-m-d'}" />
|
||||||
|
{if $errorField == 'date'}
|
||||||
|
<small class="innerError">
|
||||||
|
{lang}chat.acp.log.date.error.{$errorType}{/lang}
|
||||||
|
</small>
|
||||||
|
{/if}
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="formSubmit">
|
||||||
|
<input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="contentNavigation">
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a class="button" href="{link controller='MessageLogDownload' application='chat' object=$room date=$date|date:'Y-m-d'}{/link}">
|
||||||
|
<span class="icon icon16 icon-download-alt"></span>
|
||||||
|
<span>{lang}chat.acp.log.download{/lang}</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{if $errorField === ''}
|
||||||
|
<div id="messageLogContent" class="tabMenuContainer marginTop" data-active="timeTab-0" data-store="activeTabMenuItem" data-base-time="{$date}" data-room-id="{$room->roomID}">
|
||||||
|
<nav class="tabMenu">
|
||||||
|
<ul>
|
||||||
|
{section name=tabLoop loop=24 step=3}
|
||||||
|
<li>
|
||||||
|
{assign var=anchor value='timeTab-'|concat:$tabLoop}
|
||||||
|
<a href="{@$__wcf->getAnchor($anchor)}">{if $tabLoop < 10}0{/if}{$tabLoop}:00 - {if $tabLoop + 2 < 10}0{/if}{$tabLoop + 2}:59</a>
|
||||||
|
</li>
|
||||||
|
{/section}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{section name=contentLoop loop=24 step=3}
|
||||||
|
<div id="timeTab-{$contentLoop}" class="container containerPadding tabMenuContainer tabMenuContent" data-menu-item="timeTab-{$contentLoop}">
|
||||||
|
<nav class="menu">
|
||||||
|
<ul>
|
||||||
|
{section name=subTabLoop loop=6}
|
||||||
|
{assign var=subAnchor value='timeTab-'|concat:$contentLoop|concat:'-subTab-'|concat:$subTabLoop}
|
||||||
|
<li data-hour="{$contentLoop + $subTabLoop / 2|floor}" data-minutes="{($subTabLoop % 2) * 30}">
|
||||||
|
<a href="{@$__wcf->getAnchor($subAnchor)}">{if $contentLoop + $subTabLoop / 2 < 10}0{/if}{$contentLoop + $subTabLoop / 2|floor}:{if $subTabLoop % 2 == 0}0{/if}{($subTabLoop % 2) * 30} - {if $contentLoop + $subTabLoop / 2 < 10}0{/if}{$contentLoop + $subTabLoop / 2|floor}:{($subTabLoop % 2) * 30 + 29}</a>
|
||||||
|
</li>
|
||||||
|
{/section}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{section name=subTabLoop loop=6}
|
||||||
|
{assign var=subAnchor value='timeTab-'|concat:$contentLoop|concat:'-subTab-'|concat:$subTabLoop}
|
||||||
|
<div id="{$subAnchor}" class="hidden subTabMenuContent{if !$messages[$contentLoop * 2 + $subTabLoop]|isset} empty{else} tabularBox{/if}">
|
||||||
|
{if $messages[$contentLoop * 2 + $subTabLoop]|isset}
|
||||||
|
{include application='chat' file='__messageLogTable' sandbox='true' messages=$messages[$contentLoop * 2 + $subTabLoop]}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/section}
|
||||||
|
</div>
|
||||||
|
{/section}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{include file='footer'}
|
5
acptemplate/messageLogDownload.tpl
Normal file
5
acptemplate/messageLogDownload.tpl
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{foreach from=$messages item=$rawMessage}{*
|
||||||
|
*}{assign var=message value=$rawMessage->jsonify(true)}{*
|
||||||
|
*}({$message['time']|date:'H:i:s'}) {$message[username]|str_pad:15:' ':STR_PAD_LEFT}{$message[separator]} {$message[message]}
|
||||||
|
|
||||||
|
{/foreach}
|
92
file/acp/js/be.bastelstu.Chat.ACP.Log.litcoffee
Normal file
92
file/acp/js/be.bastelstu.Chat.ACP.Log.litcoffee
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
Tims Chat 3
|
||||||
|
===========
|
||||||
|
|
||||||
|
This is the javascript file providing functions related to the message log for [##Tims Chat##](https://github.com/wbbaddons/Tims-Chat).
|
||||||
|
|
||||||
|
### Copyright Information
|
||||||
|
# @author Maximilian Mader
|
||||||
|
# @copyright 2010-2013 Tim Düsterhus
|
||||||
|
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
|
# @package be.bastelstu.chat
|
||||||
|
###
|
||||||
|
|
||||||
|
## Code
|
||||||
|
|
||||||
|
(($, window) ->
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
_messageLogContent = null
|
||||||
|
_hasContent = {}
|
||||||
|
_proxy = null
|
||||||
|
|
||||||
|
init = ->
|
||||||
|
_messageLogContent = $ '#messageLogContent'
|
||||||
|
|
||||||
|
activeMenuItem = _messageLogContent.data 'active'
|
||||||
|
enableProxy = false
|
||||||
|
|
||||||
|
_messageLogContent.find('div.tabMenuContent > .subTabMenuContent').each (index, container) ->
|
||||||
|
containerID = $(container).wcfIdentify()
|
||||||
|
|
||||||
|
unless $("##{containerID}").hasClass 'empty'
|
||||||
|
_hasContent[containerID] = true
|
||||||
|
else
|
||||||
|
_hasContent[containerID] = false
|
||||||
|
enableProxy = true
|
||||||
|
|
||||||
|
if enableProxy
|
||||||
|
_proxy = new WCF.Action.Proxy
|
||||||
|
success: _success
|
||||||
|
|
||||||
|
_messageLogContent.bind 'wcftabsbeforeactivate',
|
||||||
|
_loadContent
|
||||||
|
|
||||||
|
if not _hasContent[activeMenuItem]
|
||||||
|
_loadContent {},
|
||||||
|
newPanel: $("##{activeMenuItem}")
|
||||||
|
newTab: $("##{activeMenuItem}").parent().find(".menu > ul > li").first()
|
||||||
|
|
||||||
|
_loadContent = (event, ui) ->
|
||||||
|
containerID = $(ui.newPanel).attr 'id'
|
||||||
|
|
||||||
|
if $("##{$(ui.newPanel).attr('id')}").hasClass 'tabMenuContainer'
|
||||||
|
containerID = $("##{containerID} > .subTabMenuContent").first().attr 'id'
|
||||||
|
tab = $("##{containerID}").parent().find(".menu > ul > li").first()
|
||||||
|
else
|
||||||
|
tab = $ ui.newTab
|
||||||
|
|
||||||
|
unless _hasContent[containerID]
|
||||||
|
start = _messageLogContent.data('baseTime') + (tab.data('hour') * 3600) + (tab.data('minutes') * 60)
|
||||||
|
|
||||||
|
_proxy.setOption 'data',
|
||||||
|
actionName: 'getMessages'
|
||||||
|
className: 'chat\\data\\message\\MessageAction'
|
||||||
|
parameters:
|
||||||
|
containerID: containerID
|
||||||
|
start: start
|
||||||
|
end: start + 1799
|
||||||
|
roomID: _messageLogContent.data 'roomID'
|
||||||
|
do _proxy.sendRequest
|
||||||
|
|
||||||
|
_success = (data, textStatus, jqWHR) ->
|
||||||
|
containerID = data.returnValues.containerID
|
||||||
|
_hasContent[containerID] = true
|
||||||
|
|
||||||
|
content = _messageLogContent.find "##{containerID}"
|
||||||
|
unless data.returnValues.template is ''
|
||||||
|
$("<div>#{data.returnValues.template}</div>").hide().appendTo content
|
||||||
|
unless data.returnValues.noMessages
|
||||||
|
content.addClass 'tabularBox'
|
||||||
|
|
||||||
|
do content.children().first().show
|
||||||
|
Log =
|
||||||
|
TabMenu:
|
||||||
|
init: init
|
||||||
|
|
||||||
|
window.be ?= {}
|
||||||
|
be.bastelstu ?= {}
|
||||||
|
be.bastelstu.Chat ?= {}
|
||||||
|
be.bastelstu.Chat.ACP ?= {}
|
||||||
|
be.bastelstu.Chat.ACP.Log ?= {}
|
||||||
|
window.be.bastelstu.Chat.ACP.Log = Log
|
||||||
|
)(jQuery, @)
|
@ -1,35 +0,0 @@
|
|||||||
###
|
|
||||||
# be.bastelstu.WCF.Chat.Log
|
|
||||||
#
|
|
||||||
# @author Tim Düsterhus
|
|
||||||
# @copyright 2010-2013 Tim Düsterhus
|
|
||||||
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
|
||||||
# @package be.bastelstu.chat
|
|
||||||
###
|
|
||||||
|
|
||||||
(($, window) ->
|
|
||||||
be.bastelstu.Chat.Log = be.bastelstu.Chat.extend
|
|
||||||
init: (@chat) ->
|
|
||||||
handleMessages: (messages) ->
|
|
||||||
# Insert the messages
|
|
||||||
for message in messages
|
|
||||||
@events.newMessage.fire message
|
|
||||||
|
|
||||||
output = @chat.messageTemplate.fetch message
|
|
||||||
li = $ '<li></li>'
|
|
||||||
li.addClass 'timsChatMessage timsChatMessage'+message.type
|
|
||||||
li.addClass 'ownMessage' if message.sender is WCF.User.userID
|
|
||||||
li.append output
|
|
||||||
|
|
||||||
li.appendTo $ '#timsChatLog .timsChatMessageContainer > ul'
|
|
||||||
|
|
||||||
be.bastelstu.Chat.Log.loadOverlay = () ->
|
|
||||||
if !$.wcfIsset 'timsChatLogDialog'
|
|
||||||
container = $ '<fieldset id="timsChatLogDialog"></fieldset>'
|
|
||||||
$('#content').append container
|
|
||||||
|
|
||||||
# TODO: Proper path
|
|
||||||
$('#timsChatLogDialog').load 'http://127.0.0.1/wbb/wbb4/index.php/Chat/Log/1-Hauptchat/', () ->
|
|
||||||
WCF.showDialog 'timsChatLogDialog',
|
|
||||||
title: 'Log'
|
|
||||||
)(jQuery, @)
|
|
136
file/lib/acp/page/MessageLogDownloadPage.class.php
Normal file
136
file/lib/acp/page/MessageLogDownloadPage.class.php
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
namespace chat\acp\page;
|
||||||
|
use \wcf\system\WCF;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles text/plain download of chat log.
|
||||||
|
*
|
||||||
|
* @author Maximilian Mader
|
||||||
|
* @copyright 2010-2013 Tim Düsterhus
|
||||||
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
|
* @package be.bastelstu.chat
|
||||||
|
* @subpackage acp.page
|
||||||
|
*/
|
||||||
|
class MessageLogDownloadPage extends \wcf\page\AbstractPage {
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\AbstractPage::$activeMenuItem
|
||||||
|
*/
|
||||||
|
public $activeMenuItem = 'chat.acp.menu.link.log';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\AbstractPage::$neededPermissions
|
||||||
|
*/
|
||||||
|
public $neededPermissions = array(
|
||||||
|
'admin.chat.canReadLog'
|
||||||
|
);
|
||||||
|
|
||||||
|
public $useTemplate = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* messages for the given day
|
||||||
|
*
|
||||||
|
* @var array<\chat\data\message\Message>
|
||||||
|
*/
|
||||||
|
public $messages = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given roomID
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $roomID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given date
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $date = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* active room
|
||||||
|
*
|
||||||
|
* @var \chat\data\room\Room
|
||||||
|
*/
|
||||||
|
public $room = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* available rooms
|
||||||
|
*
|
||||||
|
* @var array<\chat\data\room\Room>
|
||||||
|
*/
|
||||||
|
public $rooms = array();
|
||||||
|
|
||||||
|
public $tmpFile = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\IPage::readData()
|
||||||
|
*/
|
||||||
|
public function readData() {
|
||||||
|
parent::readData();
|
||||||
|
|
||||||
|
if ($this->date > TIME_NOW) {
|
||||||
|
throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->date < strtotime('today 00:00:00 -'.ceil(CHAT_LOG_ARCHIVETIME / 1440).'day')) {
|
||||||
|
throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpFile = \wcf\util\FileUtil::getTemporaryFilename();
|
||||||
|
touch($this->tmpFile);
|
||||||
|
\wcf\util\FileUtil::makeWritable($this->tmpFile);
|
||||||
|
|
||||||
|
if (is_writable($this->tmpFile)) {
|
||||||
|
$file = new \wcf\system\io\File($this->tmpFile);
|
||||||
|
$file->write(WCF::getLanguage()->get('chat.acp.log.title') . ': ' . (string) $this->room . "\n");
|
||||||
|
|
||||||
|
for ($start = $this->date, $end = $start + 86399; $start < $end; $start += 1800) {
|
||||||
|
$file->write(WCF::getTpl()->fetch('messageLogDownload', 'chat', array('messages' => \chat\data\message\MessageList::getMessagesBetween($this->room, $start, $start + 1799))));
|
||||||
|
}
|
||||||
|
|
||||||
|
$file->close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\IPage::readParameters()
|
||||||
|
*/
|
||||||
|
public function readParameters() {
|
||||||
|
parent::readParameters();
|
||||||
|
|
||||||
|
if (isset($_REQUEST['id'])) {
|
||||||
|
$this->roomID = intval($_REQUEST['id']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom($this->roomID);
|
||||||
|
if ($this->room === null) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
|
||||||
|
if (isset($_REQUEST['date'])) $date = $_REQUEST['date'].' 00:00:00';
|
||||||
|
else $date = 'today 00:00:00';
|
||||||
|
|
||||||
|
$this->date = @strtotime($date);
|
||||||
|
if ($this->date === false) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see wcf\page\IPage::show()
|
||||||
|
*/
|
||||||
|
public function show() {
|
||||||
|
parent::show();
|
||||||
|
|
||||||
|
$dateTime = \wcf\util\DateUtil::getDateTimeByTimestamp($this->date);
|
||||||
|
|
||||||
|
$fileReader = new \wcf\util\FileReader($this->tmpFile, array('mimeType' => 'text/plain', 'filename' => str_replace(' ', '-', WCF::getLanguage()->get('chat.acp.log.title') . ' ' . $this->room.'-'.\wcf\util\DateUtil::format($dateTime, 'Y-m-d').'.txt')));
|
||||||
|
$fileReader->send();
|
||||||
|
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
159
file/lib/acp/page/MessageLogPage.class.php
Normal file
159
file/lib/acp/page/MessageLogPage.class.php
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
<?php
|
||||||
|
namespace chat\acp\page;
|
||||||
|
use \wcf\system\WCF;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists chat log.
|
||||||
|
*
|
||||||
|
* @author Maximilian Mader
|
||||||
|
* @copyright 2010-2013 Tim Düsterhus
|
||||||
|
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
||||||
|
* @package be.bastelstu.chat
|
||||||
|
* @subpackage acp.page
|
||||||
|
*/
|
||||||
|
class MessageLogPage extends \wcf\page\AbstractPage {
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\AbstractPage::$activeMenuItem
|
||||||
|
*/
|
||||||
|
public $activeMenuItem = 'chat.acp.menu.link.log';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\AbstractPage::$neededPermissions
|
||||||
|
*/
|
||||||
|
public $neededPermissions = array(
|
||||||
|
'admin.chat.canReadLog'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name of error field
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $errorField = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* error type
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $errorType = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* messages for the given day
|
||||||
|
*
|
||||||
|
* @var array<\chat\data\message\Message>
|
||||||
|
*/
|
||||||
|
public $messages = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given roomID
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $roomID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given date
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
public $date = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* active room
|
||||||
|
*
|
||||||
|
* @var \chat\data\room\Room
|
||||||
|
*/
|
||||||
|
public $room = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* available rooms
|
||||||
|
*
|
||||||
|
* @var array<\chat\data\room\Room>
|
||||||
|
*/
|
||||||
|
public $rooms = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\IPage::readData()
|
||||||
|
*/
|
||||||
|
public function readData() {
|
||||||
|
parent::readData();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($this->date > TIME_NOW) {
|
||||||
|
throw new \wcf\system\exception\UserInputException('date', 'inFuture');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\wcf\system\exception\UserInputException $e) {
|
||||||
|
$this->errorField = $e->getField();
|
||||||
|
$this->errorType = $e->getType();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($this->date < strtotime('today 00:00:00 -'.ceil(CHAT_LOG_ARCHIVETIME / 1440).'day')) {
|
||||||
|
throw new \wcf\system\exception\UserInputException('date', 'tooLongAgo');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\wcf\system\exception\UserInputException $e) {
|
||||||
|
$this->errorField = $e->getField();
|
||||||
|
$this->errorType = $e->getType();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$messages = \chat\data\message\ViewableMessageList::getMessagesBetween($this->room, $this->date, $this->date + 1799);
|
||||||
|
|
||||||
|
foreach ($messages as $message) {
|
||||||
|
$hour = ((int) date('H', $message->time)) * 2;
|
||||||
|
$minutes = (int) date('i', $message->time);
|
||||||
|
|
||||||
|
if ($minutes >= 30) {
|
||||||
|
$hour += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->messages[$hour][] = $message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see \wcf\page\IPage::readParameters()
|
||||||
|
*/
|
||||||
|
public function readParameters() {
|
||||||
|
parent::readParameters();
|
||||||
|
|
||||||
|
$this->rooms = \chat\data\room\RoomCache::getInstance()->getRooms();
|
||||||
|
|
||||||
|
foreach ($this->rooms as $id => $room) {
|
||||||
|
if (!$room->permanent)
|
||||||
|
unset($this->rooms[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_REQUEST['id'])) $this->roomID = intval($_REQUEST['id']);
|
||||||
|
else $this->roomID = reset($this->rooms)->roomID;
|
||||||
|
|
||||||
|
$this->room = \chat\data\room\RoomCache::getInstance()->getRoom($this->roomID);
|
||||||
|
|
||||||
|
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
|
||||||
|
if (isset($_REQUEST['date'])) $date = $_REQUEST['date'].' 00:00:00';
|
||||||
|
else $date = 'today 00:00:00';
|
||||||
|
$this->date = @strtotime($date);
|
||||||
|
if ($this->date === false) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see wcf\page\IPage::assignVariables()
|
||||||
|
*/
|
||||||
|
public function assignVariables() {
|
||||||
|
parent::assignVariables();
|
||||||
|
|
||||||
|
WCF::getTPL()->assign(array(
|
||||||
|
'messages' => $this->messages,
|
||||||
|
'rooms' => $this->rooms,
|
||||||
|
'room' => $this->room,
|
||||||
|
'date' => $this->date,
|
||||||
|
'errorField' => $this->errorField,
|
||||||
|
'errorType' => $this->errorType
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
@ -70,7 +70,7 @@ public function __toString() {
|
|||||||
public function getFormattedMessage($type = 'text/html') {
|
public function getFormattedMessage($type = 'text/html') {
|
||||||
$message = $this->message;
|
$message = $this->message;
|
||||||
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
|
$messageParser = \wcf\system\bbcode\MessageParser::getInstance();
|
||||||
$messageParser->setOutputType('text/html');
|
$messageParser->setOutputType($type);
|
||||||
|
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case self::TYPE_JOIN:
|
case self::TYPE_JOIN:
|
||||||
@ -91,7 +91,7 @@ public function getFormattedMessage($type = 'text/html') {
|
|||||||
case self::TYPE_NORMAL:
|
case self::TYPE_NORMAL:
|
||||||
case self::TYPE_ME:
|
case self::TYPE_ME:
|
||||||
default:
|
default:
|
||||||
if ($type !== 'text/html') return $message;
|
if ($type === 'text/plain') return $message;
|
||||||
|
|
||||||
$message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false);
|
$message = $messageParser->parse($message, $this->enableSmilies, $this->enableHTML, true, false);
|
||||||
break;
|
break;
|
||||||
|
@ -164,4 +164,37 @@ public function send() {
|
|||||||
// add activity points
|
// add activity points
|
||||||
\wcf\system\user\activity\point\UserActivityPointHandler::getInstance()->fireEvent('be.bastelstu.chat.activityPointEvent.message', $returnValues['returnValues']->messageID, WCF::getUser()->userID);
|
\wcf\system\user\activity\point\UserActivityPointHandler::getInstance()->fireEvent('be.bastelstu.chat.activityPointEvent.message', $returnValues['returnValues']->messageID, WCF::getUser()->userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches messages in between the specified timestamps.
|
||||||
|
*
|
||||||
|
* @return array Array containing message table, containerID and information about an empty message table.
|
||||||
|
*/
|
||||||
|
public function getMessages() {
|
||||||
|
// read messages
|
||||||
|
$messages = ViewableMessageList::getMessagesBetween($this->parameters['room'], $this->parameters['start'], $this->parameters['end']);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'noMessages' => (count($messages) == 0) ? true : null,
|
||||||
|
'containerID' => $this->parameters['containerID'],
|
||||||
|
'template' => WCF::getTPL()->fetch('__messageLogTable', 'chat', array('messages' => $messages), true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates getting messages.
|
||||||
|
*/
|
||||||
|
public function validateGetMessages() {
|
||||||
|
// check permissions
|
||||||
|
WCF::getSession()->checkPermissions(array('admin.chat.canReadLog'));
|
||||||
|
|
||||||
|
// read parameters
|
||||||
|
$this->readInteger('roomID');
|
||||||
|
$this->readInteger('start');
|
||||||
|
$this->readInteger('end');
|
||||||
|
|
||||||
|
// read and validate room
|
||||||
|
$this->parameters['room'] = room\RoomCache::getInstance()->getRoom($this->parameters['roomID']);
|
||||||
|
if ($this->parameters['room'] === null) throw new \wcf\system\exception\IllegalLinkException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,23 @@ public static function getMessagesSince(\chat\data\room\Room $room, $since) {
|
|||||||
$messageList->readObjects();
|
$messageList->readObjects();
|
||||||
return $messageList->getObjects();
|
return $messageList->getObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the message between the given timestamps for the given room.
|
||||||
|
*
|
||||||
|
* @param \chat\data\room\Room $room
|
||||||
|
* @param integer $start
|
||||||
|
* @param integer $end
|
||||||
|
* @return array<\chat\data\message\Message>
|
||||||
|
*/
|
||||||
|
public static function getMessagesBetween(\chat\data\room\Room $room, $start, $end) {
|
||||||
|
$messageList = new static();
|
||||||
|
$messageList->sqlOrderBy = "message.messageID ASC";
|
||||||
|
$messageList->getConditionBuilder()->add('message.receiver IS NULL', array());
|
||||||
|
$messageList->getConditionBuilder()->add('message.roomID = ?', array($room->roomID));
|
||||||
|
$messageList->getConditionBuilder()->add('message.time BETWEEN ? AND ?', array($start, $end));
|
||||||
|
|
||||||
|
$messageList->readObjects();
|
||||||
|
return $messageList->getObjects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace chat\page;
|
|
||||||
use \chat\data;
|
|
||||||
use \wcf\system\exception\IllegalLinkException;
|
|
||||||
use \wcf\system\exception\PermissionDeniedException;
|
|
||||||
use \wcf\system\WCF;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the chat-log.
|
|
||||||
*
|
|
||||||
* @author Tim Düsterhus
|
|
||||||
* @copyright 2010-2013 Tim Düsterhus
|
|
||||||
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
|
||||||
* @package be.bastelstu.chat
|
|
||||||
* @subpackage page
|
|
||||||
*/
|
|
||||||
class LogPage extends \wcf\page\AbstractPage {
|
|
||||||
/**
|
|
||||||
* @see wcf\page\AbstractPage::$loginRequired
|
|
||||||
*/
|
|
||||||
public $loginRequired = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: comment this
|
|
||||||
*
|
|
||||||
* @var array<\wcf\data\chat\message\ChatMessage>
|
|
||||||
*/
|
|
||||||
public $messages = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \wcf\page\AbstractPage::$neededModules
|
|
||||||
*/
|
|
||||||
public $neededModules = array('MODULE_CHAT');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \wcf\page\AbstractPage::$neededPermissions
|
|
||||||
*/
|
|
||||||
public $neededPermissions = array('mod.chat.canReadLog');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* given roomID
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $roomID = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* given room
|
|
||||||
* @var \chat\data\room\Chat
|
|
||||||
*/
|
|
||||||
public $room = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \wcf\page\IPage::assignVariables()
|
|
||||||
*/
|
|
||||||
public function assignVariables() {
|
|
||||||
parent::assignVariables();
|
|
||||||
|
|
||||||
WCF::getTPL()->assign(array(
|
|
||||||
'messages' => $this->messages,
|
|
||||||
'room' => $this->room,
|
|
||||||
'roomID' => $this->roomID
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \wcf\page\IPage::readParameters()
|
|
||||||
*/
|
|
||||||
public function readParameters() {
|
|
||||||
parent::readParameters();
|
|
||||||
|
|
||||||
if (isset($_REQUEST['id'])) $this->roomID = intval($_REQUEST['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see \wcf\page\IPage::readData()
|
|
||||||
*/
|
|
||||||
public function readData() {
|
|
||||||
parent::readData();
|
|
||||||
|
|
||||||
$this->room = data\room\RoomCache::getInstance()->getRoom($this->roomID);
|
|
||||||
if (!$this->room) throw new IllegalLinkException();
|
|
||||||
if (!$this->room->canEnter()) throw new PermissionDeniedException();
|
|
||||||
|
|
||||||
// TODO: actually read the correct messages
|
|
||||||
$this->messages = data\message\MessageList::getNewestMessages($this->room, 150);
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,8 +21,17 @@
|
|||||||
<item name="chat.acp.suspension.revokedBy"><![CDATA[Zurückgezogen von {$suspension->revokerUsername}]]></item>
|
<item name="chat.acp.suspension.revokedBy"><![CDATA[Zurückgezogen von {$suspension->revokerUsername}]]></item>
|
||||||
</category>
|
</category>
|
||||||
|
|
||||||
|
<category name="chat.acp.log">
|
||||||
|
<item name="chat.acp.log.title"><![CDATA[Nachrichten-Protokoll]]></item>
|
||||||
|
<item name="chat.acp.log.download"><![CDATA[Tages-Protokoll herunterladen]]></item>
|
||||||
|
<item name="chat.acp.log.message"><![CDATA[Nachricht]]></item>
|
||||||
|
<item name="chat.acp.log.date.error.inFuture"><![CDATA[Das angegebene Datum befindet sich in der Zukunft.]]></item>
|
||||||
|
<item name="chat.acp.log.date.error.tooLongAgo"><![CDATA[Das angegebene Datum befindet sich außerhalb der protokollierten Zeitspanne von {CHAT_LOG_ARCHIVETIME / 1440|ceil} Tagen.]]></item>
|
||||||
|
</category>
|
||||||
|
|
||||||
<category name="chat.acp.menu">
|
<category name="chat.acp.menu">
|
||||||
<item name="chat.acp.menu.link"><![CDATA[Chat]]></item>
|
<item name="chat.acp.menu.link"><![CDATA[Chat]]></item>
|
||||||
|
<item name="chat.acp.menu.link.log"><![CDATA[Nachrichten-Protokoll]]></item>
|
||||||
<item name="chat.acp.menu.link.room.list"><![CDATA[Chaträume auflisten]]></item>
|
<item name="chat.acp.menu.link.room.list"><![CDATA[Chaträume auflisten]]></item>
|
||||||
<item name="chat.acp.menu.link.room.add"><![CDATA[Chatraum hinzufügen]]></item>
|
<item name="chat.acp.menu.link.room.add"><![CDATA[Chatraum hinzufügen]]></item>
|
||||||
<item name="chat.acp.menu.link.suspension.list"><![CDATA[Sanktionen auflisten]]></item>
|
<item name="chat.acp.menu.link.suspension.list"><![CDATA[Sanktionen auflisten]]></item>
|
||||||
|
@ -56,12 +56,6 @@
|
|||||||
title: '<img width="246" height="90" alt="" src="{$__wcf->getPath("chat")|encodeJS}images/chatLogo.png"> {if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}'
|
title: '<img width="246" height="90" alt="" src="{$__wcf->getPath("chat")|encodeJS}images/chatLogo.png"> {if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#chatLogLink').click(function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
be.bastelstu.Chat.Log.loadOverlay();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})(jQuery, this);
|
})(jQuery, this);
|
||||||
//]]>
|
//]]>
|
||||||
@ -70,7 +64,6 @@
|
|||||||
|
|
||||||
<body id="tpl{$templateName|ucfirst}">
|
<body id="tpl{$templateName|ucfirst}">
|
||||||
{capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture}
|
{capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture}
|
||||||
{capture assign='headerNavigation'}{include application='chat' file='navigationInclude'}{/capture}
|
|
||||||
{include file='header' sandbox=false sidebarOrientation='right'}
|
{include file='header' sandbox=false sidebarOrientation='right'}
|
||||||
|
|
||||||
<div id="timsChatTopic" class="container{if $room->topic|language === ''} empty{/if}">
|
<div id="timsChatTopic" class="container{if $room->topic|language === ''} empty{/if}">
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
{if $__wcf->session->getPermission('mod.chat.canReadLog')}
|
|
||||||
<li>
|
|
||||||
<a id="chatLogLink" title="{lang}chat.general.protocol{/lang}" class="jsTooltip">
|
|
||||||
<span class="icon icon16 icon-eye-open"></span> <span>{lang}chat.general.protocol{/lang}</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
@ -80,12 +80,6 @@
|
|||||||
<defaultvalue>0</defaultvalue>
|
<defaultvalue>0</defaultvalue>
|
||||||
<admindefaultvalue>1</admindefaultvalue>
|
<admindefaultvalue>1</admindefaultvalue>
|
||||||
</option>
|
</option>
|
||||||
<option name="mod.chat.canReadLog">
|
|
||||||
<categoryname>mod.chat</categoryname>
|
|
||||||
<optiontype>boolean</optiontype>
|
|
||||||
<defaultvalue>0</defaultvalue>
|
|
||||||
<admindefaultvalue>1</admindefaultvalue>
|
|
||||||
</option>
|
|
||||||
<option name="admin.chat.canAddRoom">
|
<option name="admin.chat.canAddRoom">
|
||||||
<categoryname>admin.chat</categoryname>
|
<categoryname>admin.chat</categoryname>
|
||||||
<optiontype>boolean</optiontype>
|
<optiontype>boolean</optiontype>
|
||||||
@ -104,6 +98,12 @@
|
|||||||
<defaultvalue>0</defaultvalue>
|
<defaultvalue>0</defaultvalue>
|
||||||
<admindefaultvalue>1</admindefaultvalue>
|
<admindefaultvalue>1</admindefaultvalue>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="admin.chat.canReadLog">
|
||||||
|
<categoryname>admin.chat</categoryname>
|
||||||
|
<optiontype>boolean</optiontype>
|
||||||
|
<defaultvalue>0</defaultvalue>
|
||||||
|
<admindefaultvalue>1</admindefaultvalue>
|
||||||
|
</option>
|
||||||
<option name="admin.chat.canManageSuspensions">
|
<option name="admin.chat.canManageSuspensions">
|
||||||
<categoryname>admin.chat</categoryname>
|
<categoryname>admin.chat</categoryname>
|
||||||
<optiontype>boolean</optiontype>
|
<optiontype>boolean</optiontype>
|
||||||
|
Loading…
Reference in New Issue
Block a user