1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Add filter form to ChatSuspensionList

This commit is contained in:
Maximilian Mader 2013-06-15 15:33:30 +02:00
parent 7ae862c808
commit 2ec2b17a7f
3 changed files with 111 additions and 8 deletions

View File

@ -22,5 +22,12 @@
<permissions>admin.chat.canAddRoom</permissions>
<showorder>2</showorder>
</acpmenuitem>
<acpmenuitem name="chat.acp.menu.link.suspension.list">
<controller><![CDATA[chat\acp\page\SuspensionListPage]]></controller>
<parent>chat.acp.menu.link.chat</parent>
<!--TODO: <permissions></permissions> -->
<showorder>1</showorder>
</acpmenuitem>
</import>
</data>

View File

@ -1,9 +1,69 @@
{include file='header' pageTitle='chat.acp.suspension.list'}
<script type="text/javascript">
//<![CDATA[
$(function() {
new WCF.Search.User('#username', null, false, [ ], false);
new WCF.Search.User('#issuerUsername', null, false, [ ], false);
});
//]]>
</script>
<header class="boxHeadline">
<h1>{lang}chat.acp.suspension.list{/lang}</h1>
</header>
<form method="post" action="{link controller='ChatSuspensionList' application="chat"}{/link}">
<div class="container containerPadding marginTop">
<fieldset>
<legend>{lang}wcf.global.filter{/lang}</legend>
<dl>
<dt><label for="username">{lang}wcf.user.username{/lang}</label></dt>
<dd>
<input type="text" id="username" name="username" class="long" value="{$filterUsername}" />
</dd>
</dl>
<dl>
<dt><label for="issuerUsername">{lang}wcf.acp.chat.issuer{/lang}</label></dt>
<dd>
<input type="text" id="issuerUsername" name="issuerUsername" class="long" value="{$filterIssuerUsername}" />
</dd>
</dl>
<dl>
<dt><label for="roomID">{lang}chat.general.room{/lang}</label></dt>
<dd>
<select name="roomID">
<option value="-1" {if $filterRoomID == -1}selected="selected"{/if}></option>
<option value="0" {if $filterRoomID == 0}selected="selected"{/if}>{lang}chat.room.global{/lang}</option>
<option value="" disabled="disabled">&mdash;&mdash;&mdash;&mdash;</option>
{foreach from=$availableRooms key=id item=room}
<option value="{$id}" {if $filterRoomID == $id}selected="selected"{/if}>{$room}</option>
{/foreach}
</select>
</dd>
</dl>
<dl>
<dt><label for="searchTypeMute">{lang}wcf.acp.chat.suspensionType{/lang}</label></dt>
<dd>
<select name="suspensionType" id="suspensionType">
<option value=""{if $filterSuspensionType == null}selected="selected"{/if}></option>
<option value="{'\chat\data\suspension\Suspension::TYPE_MUTE'|constant}"{if $filterSuspensionType == '\chat\data\suspension\Suspension::TYPE_MUTE'|constant} selected="selected"{/if}>{lang}chat.suspension.{'\chat\data\suspension\Suspension::TYPE_MUTE'|constant}{/lang}</option>
<option value="{'\chat\data\suspension\Suspension::TYPE_BAN'|constant}"{if $filterSuspensionType == '\chat\data\suspension\Suspension::TYPE_BAN'|constant} selected="selected"{/if}>{lang}chat.suspension.{'\chat\data\suspension\Suspension::TYPE_BAN'|constant}{/lang}</option>
</select>
</dd>
</dl>
</fieldset>
</div>
<div class="formSubmit">
<input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
</div>
</form>
{if $objects|count}
<div class="tabularBox tabularBoxTitle marginTop">
<header>
@ -16,7 +76,7 @@
<th class="columnID{if $sortField == 'suspensionID'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=suspensionID&sortOrder={if $sortField == 'suspensionID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
<th class="columnUsername{if $sortField == 'username'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=username&sortOrder={if $sortField == 'username' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.user.username{/lang}</a></th>
<th class="columnRoomID{if $sortField == 'roomID'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=roomID&sortOrder={if $sortField == 'roomID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}chat.general.room{/lang}</a></th>
<th class="columnType{if $sortField == 'type'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=type&sortOrder={if $sortField == 'type' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.chat.type{/lang}</a></th>
<th class="columnSuspensionType{if $sortField == 'suspensionType'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=suspensionType&sortOrder={if $sortField == 'suspensionType' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.chat.suspensionType{/lang}</a></th>
<th class="columnTime{if $sortField == 'time'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=time&sortOrder={if $sortField == 'time' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.chat.time{/lang}</a></th>
<th class="columnExpires{if $sortField == 'expires'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=expires&sortOrder={if $sortField == 'expires' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.chat.expires{/lang}</a></th>
<th class="columnIssuer{if $sortField == 'issuer'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='ChatSuspensionList'}pageNo={@$pageNo}&sortField=issuer&sortOrder={if $sortField == 'issuer' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.chat.issuer{/lang}</a></th>
@ -29,7 +89,7 @@
<td id="columnID">{@$suspension->suspensionID}</td>
<td id="columnUsername"><a href="{link application='chat' controller='ChatSuspensionList'}userID={$suspension->userID}{/link}">{$suspension->username}</a></td>
<td id="columnRoomID"><a href="{link application='chat' controller='ChatSuspensionList'}roomID={if $suspension->roomID}{$suspension->roomID}{else}0{/if}{/link}">{if $suspension->roomID}{@$suspension->roomTitle|language}{else}{lang}chat.room.global{/lang}{/if}</a></td>
<td id="columnType"><a href="{link application='chat' controller='ChatSuspensionList'}type={$suspension->type}{/link}">{lang}chat.suspension.{@$suspension->type}{/lang}</a></td>
<td id="columnSuspensionType"><a href="{link application='chat' controller='ChatSuspensionList'}suspensionType={$suspension->type}{/link}">{lang}chat.suspension.{@$suspension->type}{/lang}</a></td>
<td id="columnTime">{@$suspension->time|plainTime}</td>
<td id="columnExpires">{@$suspension->expires|plainTime} ({$suspension->expires|dateDiff})</td>
<td id="columnIssuer"><a href="{link application='chat' controller='ChatSuspensionList'}issuerUserID={$suspension->issuer}{/link}">{$suspension->issuerUsername}</a></td>

View File

@ -48,7 +48,7 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage {
*
* @var integer
*/
public $filterType = null;
public $filterSuspensionType = null;
/**
* user filter
@ -57,6 +57,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage {
*/
public $filterUserID = null;
/*
* username
*
* @var String
*/
public $filterUsername = null;
/**
* issuer filter
*
@ -64,6 +71,13 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage {
*/
public $filterIssuerUserID = null;
/*
* issuer username
*
* @var String
*/
public $filterIssuerUsername = null;
/**
* room filter
*
@ -77,10 +91,32 @@ class ChatSuspensionListPage extends \wcf\page\SortablePage {
public function readParameters() {
parent::readParameters();
if (isset($_REQUEST['type'])) $this->filterType = intval($_REQUEST['type']);
if (isset($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']);
if (isset($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']);
if (isset($_REQUEST['roomID'])) $this->filterRoomID = intval($_REQUEST['roomID']);
if (isset($_REQUEST['username']) && !empty($_REQUEST['username'])) $this->filterUsername = \wcf\util\StringUtil::trim($_REQUEST['username']);
if (isset($_REQUEST['issuerUsername']) && !empty($_REQUEST['issuerUsername'])) $this->filterIssuerUsername = \wcf\util\StringUtil::trim($_REQUEST['issuerUsername']);
if ($this->filterUsername != null) $this->filterUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterUsername)->userID;
if ($this->filterIssuerUsername != null) $this->filterIssuerUserID = \wcf\data\user\UserProfile::getUserProfileByUsername($this->filterIssuerUsername)->userID;
if ($this->filterUserID === null && isset($_REQUEST['userID']) && !empty($_REQUEST['userID'])) $this->filterUserID = intval($_REQUEST['userID']);
if ($this->filterIssuerUserID === null && isset($_REQUEST['issuerUserID']) && !empty($_REQUEST['issuerUserID'])) $this->filterIssuerUserID = intval($_REQUEST['issuerUserID']);
if (isset($_REQUEST['roomID']) && $_REQUEST['roomID'] != -1) $this->filterRoomID = intval($_REQUEST['roomID']);
if (isset($_REQUEST['suspensionType']) && !empty($_REQUEST['suspensionType'])) $this->filterSuspensionType = intval($_REQUEST['suspensionType']);
}
/**
* @see wcf\page\IPage::assignVariables()
*/
public function assignVariables() {
parent::assignVariables();
WCF::getTPL()->assign(array(
'availableRooms' => \chat\data\room\RoomCache::getInstance()->getRooms(),
'filterRoomID' => ($this->filterRoomID !== null) ? $this->filterRoomID : -1,
'filterUsername' => $this->filterUsername,
'filterIssuerUsername' => $this->filterIssuerUsername,
'filterSuspensionType' => $this->filterSuspensionType
));
}
/**
@ -102,7 +138,7 @@ protected function initObjectList() {
$this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW));
$this->objectList->getConditionBuilder()->add('(room_table.permanent = ? OR suspension.roomID IS NULL)', array(1));
if ($this->filterType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterType));
if ($this->filterSuspensionType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterSuspensionType));
if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID));
if ($this->filterIssuerUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.issuer = ?', array($this->filterIssuerUserID));
if ($this->filterRoomID !== null) {