mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Add filter to suspensionList
This commit is contained in:
parent
63399908f1
commit
c224333b10
@ -13,11 +13,11 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="columnID{if $sortField == 'suspensionID'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='SuspensionList'}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='SuspensionList'}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='SuspensionList'}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='SuspensionList'}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="columnExpires{if $sortField == 'expires'} active {@$sortOrder}{/if}"><a href="{link application='chat' controller='SuspensionList'}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="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="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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
{foreach from=$objects item=$suspension}
|
||||
<tr>
|
||||
<td id="columnID">{@$suspension->suspensionID}</td>
|
||||
<td id="columnUsername">{$suspension->username}</td>
|
||||
<td id="columnRoomID">{if $suspension->roomID}{@$suspension->roomID}{else}{lang}chat.room.global{/lang}{/if}</td>
|
||||
<td id="columnType">{lang}chat.suspension.{@$suspension->type}{/lang}</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="columnExpires">{@$suspension->expires|time} ({@$suspension->expires|dateDiff})</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
@ -35,7 +35,7 @@
|
||||
</table>
|
||||
</div>
|
||||
{else}
|
||||
<p class="warning">{lang}chat.acp.suspension.noItems{/lang}</p>
|
||||
<p class="info">{lang}chat.acp.suspension.noItems{/lang}</p>
|
||||
{/if}
|
||||
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
* Lists chat suspensions.
|
||||
*
|
||||
* @author Maximilian Mader
|
||||
* @copyright 2010-2013 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 acp.page
|
||||
*/
|
||||
class SuspensionListPage extends \wcf\page\SortablePage {
|
||||
class ChatSuspensionListPage extends \wcf\page\SortablePage {
|
||||
/**
|
||||
* @see \wcf\page\AbstractPage::$activeMenuItem
|
||||
*/
|
||||
@ -20,37 +20,87 @@ class SuspensionListPage extends \wcf\page\SortablePage {
|
||||
/**
|
||||
* @see \wcf\page\AbstractPage::$neededPermissions
|
||||
*/
|
||||
// TODO: Permissions
|
||||
public $neededPermissions = array();
|
||||
|
||||
/**
|
||||
* @see wcf\page\SortablePage::$defaultSortField
|
||||
* @see \wcf\page\SortablePage::$defaultSortField
|
||||
*/
|
||||
public $defaultSortField = 'username';
|
||||
public $defaultSortField = 'expires';
|
||||
|
||||
/**
|
||||
* @see wcf\page\MultipleLinkPage::$itemsPerPage
|
||||
* @see \wcf\page\MultipleLinkPage::$itemsPerPage
|
||||
*/
|
||||
public $itemsPerPage = 50;
|
||||
public $itemsPerPage = 30;
|
||||
|
||||
/**
|
||||
* @see wcf\page\SortablePage::$validSortFields
|
||||
* @see \wcf\page\SortablePage::$validSortFields
|
||||
*/
|
||||
public $validSortFields = array('suspensionID', 'userID', 'username', 'roomID', 'type', 'expires');
|
||||
|
||||
/**
|
||||
* @see wcf\page\MultipleLinkPage::$objectListClassName
|
||||
* @see \wcf\page\MultipleLinkPage::$objectListClassName
|
||||
*/
|
||||
public $objectListClassName = 'chat\data\suspension\SuspensionList';
|
||||
|
||||
/**
|
||||
* @see wcf\page\MultipleLinkPage::readObjects()
|
||||
* type filter
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $filterType = null;
|
||||
|
||||
/**
|
||||
* user filter
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $filterUserID = null;
|
||||
|
||||
/**
|
||||
* room filter
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $filterRoomID = null;
|
||||
|
||||
/**
|
||||
* @see \wcf\page\IPage::readParameters()
|
||||
*/
|
||||
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['roomID'])) $this->filterRoomID = intval($_REQUEST['roomID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \wcf\page\MultipleLinkPage::readObjects()
|
||||
*/
|
||||
protected function initObjectList() {
|
||||
parent::initObjectList();
|
||||
|
||||
$this->objectList->sqlSelects .= "user_table.username";
|
||||
$this->objectList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table
|
||||
$this->objectList->sqlSelects .= "user_table.username, room_table.title AS roomTitle";
|
||||
$this->objectList->sqlJoins .= "
|
||||
LEFT JOIN wcf".WCF_N."_user user_table
|
||||
ON suspension.userID = user_table.userID";
|
||||
$conditionJoins = " LEFT JOIN chat".WCF_N."_room room_table
|
||||
ON suspension.roomID = room_table.roomID";
|
||||
$this->objectList->sqlConditionJoins .= $conditionJoins;
|
||||
$this->objectList->sqlJoins .= $conditionJoins;
|
||||
|
||||
$this->objectList->getConditionBuilder()->add('expires >= ?', array(TIME_NOW));
|
||||
$this->objectList->getConditionBuilder()->add('room_table.permanent = ?', array(1));
|
||||
if ($this->filterType !== null) $this->objectList->getConditionBuilder()->add('suspension.type = ?', array($this->filterType));
|
||||
if ($this->filterUserID !== null) $this->objectList->getConditionBuilder()->add('suspension.userID = ?', array($this->filterUserID));
|
||||
if ($this->filterRoomID !== null) {
|
||||
if ($this->filterRoomID === 0) {
|
||||
$this->objectList->getConditionBuilder()->add('suspension.roomID IS NULL', array());
|
||||
}
|
||||
else {
|
||||
$this->objectList->getConditionBuilder()->add('suspension.roomID = ?', array($this->filterRoomID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user