2013-06-04 20:54:11 +00:00
< ? php
namespace chat\acp\page ;
use \wcf\system\WCF ;
/**
* Lists chat suspensions .
*
* @ author Maximilian Mader
2013-06-06 14:46:27 +00:00
* @ copyright 2010 - 2013 Tim Düsterhus
2013-06-04 20:54:11 +00:00
* @ license Creative Commons Attribution - NonCommercial - ShareAlike < http :// creativecommons . org / licenses / by - nc - sa / 3.0 / legalcode >
* @ package be . bastelstu . chat
* @ subpackage acp . page
*/
2013-06-06 14:46:27 +00:00
class ChatSuspensionListPage extends \wcf\page\SortablePage {
2013-06-04 20:54:11 +00:00
/**
* @ see \wcf\page\AbstractPage :: $activeMenuItem
*/
public $activeMenuItem = 'chat.acp.menu.link.suspension.list' ;
/**
* @ see \wcf\page\AbstractPage :: $neededPermissions
*/
2013-06-22 15:40:24 +00:00
public $neededPermissions = array ( 'mod.chat.canViewAllSuspensions' );
2013-06-04 20:54:11 +00:00
/**
2013-06-06 14:56:13 +00:00
* @ see \wcf\page\SortablePage :: $defaultSortField
*/
2013-06-06 14:46:27 +00:00
public $defaultSortField = 'expires' ;
2013-06-04 20:54:11 +00:00
/**
2013-06-06 14:56:13 +00:00
* @ see \wcf\page\SortablePage :: $validSortFields
*/
2013-06-22 00:19:52 +00:00
public $validSortFields = array ( 'suspensionID' , 'userID' , 'username' , 'roomID' , 'type' , 'expires' , 'issuer' , 'time' , 'reason' );
2013-06-04 20:54:11 +00:00
/**
2013-06-06 14:56:13 +00:00
* @ see \wcf\page\MultipleLinkPage :: $objectListClassName
*/
2013-06-04 20:54:11 +00:00
public $objectListClassName = 'chat\data\suspension\SuspensionList' ;
/**
2013-06-06 14:46:27 +00:00
* type filter
*
* @ var integer
*/
2013-06-15 13:33:30 +00:00
public $filterSuspensionType = null ;
2013-06-06 14:46:27 +00:00
/**
* user filter
*
* @ var integer
*/
public $filterUserID = null ;
2013-06-15 13:33:30 +00:00
/*
* username
*
* @ var String
*/
public $filterUsername = null ;
2013-06-12 20:49:25 +00:00
/**
* issuer filter
*
* @ var integer
*/
public $filterIssuerUserID = null ;
2013-06-15 13:33:30 +00:00
/*
* issuer username
*
* @ var String
*/
public $filterIssuerUsername = null ;
2013-06-06 14:46:27 +00:00
/**
* room filter
*
* @ var integer
*/
public $filterRoomID = null ;
2013-06-22 12:40:54 +00:00
/**
* display revoked suspensions
*
* @ var integer
*/
public $displayRevoked = 0 ;
2013-06-06 14:46:27 +00:00
/**
* @ see \wcf\page\IPage :: readParameters ()
*/
public function readParameters () {
parent :: readParameters ();
2013-06-15 19:02:10 +00:00
// get usernames
2013-06-15 13:33:30 +00:00
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' ]);
2013-06-15 19:02:10 +00:00
// get user IDs by username
2013-06-15 13:33:30 +00:00
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 ;
2013-06-15 19:02:10 +00:00
// get user IDs by request if no username was sent
if ( $this -> filterUserID === null && isset ( $_REQUEST [ 'userID' ]) && ! empty ( $_REQUEST [ 'userID' ])) $this -> filterUserID = intval ( $_REQUEST [ 'userID' ]);
2013-06-15 13:33:30 +00:00
if ( $this -> filterIssuerUserID === null && isset ( $_REQUEST [ 'issuerUserID' ]) && ! empty ( $_REQUEST [ 'issuerUserID' ])) $this -> filterIssuerUserID = intval ( $_REQUEST [ 'issuerUserID' ]);
2013-06-15 19:02:10 +00:00
// get usernames by ID if no usernames were sent
if ( $this -> filterUsername === null ) $this -> filterUsername = \wcf\data\user\UserProfile :: getUserProfile ( $this -> filterUserID );
if ( $this -> filterIssuerUsername === null ) $this -> filterIssuerUsername = \wcf\data\user\UserProfile :: getUserProfile ( $this -> filterIssuerUserID );
// get room IDs by request
2013-06-15 13:33:30 +00:00
if ( isset ( $_REQUEST [ 'roomID' ]) && $_REQUEST [ 'roomID' ] != - 1 ) $this -> filterRoomID = intval ( $_REQUEST [ 'roomID' ]);
if ( isset ( $_REQUEST [ 'suspensionType' ]) && ! empty ( $_REQUEST [ 'suspensionType' ])) $this -> filterSuspensionType = intval ( $_REQUEST [ 'suspensionType' ]);
2013-06-22 12:40:54 +00:00
// display revoked
if ( isset ( $_REQUEST [ 'displayRevoked' ])) $this -> displayRevoked = intval ( $_REQUEST [ 'displayRevoked' ]);
2013-06-15 13:33:30 +00:00
}
/**
* @ see wcf\page\IPage :: assignVariables ()
*/
public function assignVariables () {
parent :: assignVariables ();
WCF :: getTPL () -> assign ( array (
'availableRooms' => \chat\data\room\RoomCache :: getInstance () -> getRooms (),
2013-06-21 18:18:33 +00:00
'roomID' => ( $this -> filterRoomID !== null ) ? $this -> filterRoomID : - 1 ,
'username' => $this -> filterUsername ,
'issuerUsername' => $this -> filterIssuerUsername ,
'suspensionType' => $this -> filterSuspensionType ,
'userID' => $this -> filterUserID ,
2013-06-22 12:40:54 +00:00
'issuerUserID' => $this -> filterIssuerUserID ,
'displayRevoked' => $this -> displayRevoked
2013-06-15 13:33:30 +00:00
));
2013-06-06 14:46:27 +00:00
}
/**
* @ see \wcf\page\MultipleLinkPage :: readObjects ()
2013-06-04 20:54:11 +00:00
*/
protected function initObjectList () {
parent :: initObjectList ();
2013-06-22 14:31:08 +00:00
$this -> objectList -> sqlSelects .= " user_table.username, user_table2.username AS issuerUsername, user_table3.username AS revokerUsername, room_table.title AS roomTitle " ;
2013-06-06 14:46:27 +00:00
$this -> objectList -> sqlJoins .= "
LEFT JOIN wcf " .WCF_N. " _user user_table
2013-06-12 20:49:25 +00:00
ON suspension . userID = user_table . userID
LEFT JOIN wcf " .WCF_N. " _user user_table2
2013-06-22 14:31:08 +00:00
ON suspension . issuer = user_table2 . userID
LEFT JOIN wcf " .WCF_N. " _user user_table3
2013-06-22 15:40:24 +00:00
ON suspension . issuer = user_table3 . userID " ;
2013-06-06 14:46:27 +00:00
$conditionJoins = " LEFT JOIN chat " . WCF_N . " _room room_table
ON suspension . roomID = room_table . roomID " ;
$this -> objectList -> sqlConditionJoins .= $conditionJoins ;
$this -> objectList -> sqlJoins .= $conditionJoins ;
2013-06-22 12:40:54 +00:00
if ( ! $this -> displayRevoked ) {
2013-06-22 14:17:53 +00:00
$this -> objectList -> getConditionBuilder () -> add ( 'expires > ?' , array ( TIME_NOW ));
2013-06-22 12:40:54 +00:00
}
2013-06-06 18:51:25 +00:00
$this -> objectList -> getConditionBuilder () -> add ( '(room_table.permanent = ? OR suspension.roomID IS NULL)' , array ( 1 ));
2013-06-15 13:33:30 +00:00
if ( $this -> filterSuspensionType !== null ) $this -> objectList -> getConditionBuilder () -> add ( 'suspension.type = ?' , array ( $this -> filterSuspensionType ));
2013-06-06 14:46:27 +00:00
if ( $this -> filterUserID !== null ) $this -> objectList -> getConditionBuilder () -> add ( 'suspension.userID = ?' , array ( $this -> filterUserID ));
2013-06-12 20:49:25 +00:00
if ( $this -> filterIssuerUserID !== null ) $this -> objectList -> getConditionBuilder () -> add ( 'suspension.issuer = ?' , array ( $this -> filterIssuerUserID ));
2013-06-06 14:46:27 +00:00
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 ));
}
}
2013-06-04 20:54:11 +00:00
}
}