mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Add message log to ACP.
This commit is contained in:
parent
b1277178ca
commit
495680c3d3
77
acptemplate/messageLog.tpl
Normal file
77
acptemplate/messageLog.tpl
Normal file
@ -0,0 +1,77 @@
|
||||
{include file='header' pageTitle='chat.acp.log.title'}
|
||||
|
||||
<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>
|
||||
|
||||
{if $messages|count == 0}
|
||||
{if $errorField === ""}
|
||||
<p class="info">{lang}wcf.global.noItems{/lang}</p>
|
||||
{/if}
|
||||
{else}
|
||||
<div class="tabularBox tabularBoxTitle marginTop">
|
||||
<header>
|
||||
<h2>{lang}chat.acp.log.title{/lang} <span class="badge badgeInverse">{#$messages|count}</span></h2>
|
||||
</header>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{include file='footer'}
|
144
file/lib/acp/page/MessageLogPage.class.php
Normal file
144
file/lib/acp/page/MessageLogPage.class.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?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(
|
||||
'mod.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;
|
||||
}
|
||||
|
||||
$this->messages = \chat\data\message\ViewableMessageList::getMessagesBetween($this->room, $this->date, $this->date + 86399);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user