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

Show suspensions in InfoCommand

This commit is contained in:
Tim Düsterhus 2013-04-23 16:16:27 +02:00
parent 87c7fdd03d
commit 2c1d016d41
4 changed files with 20 additions and 7 deletions

View File

@ -45,14 +45,14 @@ public function canEnter(\wcf\data\user\User $user = null) {
$canEnter = $ph->getPermission($this, 'user.canEnter');
// room suspension
if ($canEnter && isset($suspensions[$this->roomID][Suspension::TYPE_BAN])) {
if ($suspensions[$this->roomID][Suspension::TYPE_BAN]['time'] > TIME_NOW) {
if ($suspensions[$this->roomID][Suspension::TYPE_BAN]->time > TIME_NOW) {
$canEnter = false;
}
}
// global suspension
if ($canEnter && isset($suspensions[null][Suspension::TYPE_BAN])) {
if ($suspensions[null][Suspension::TYPE_BAN]['time'] > TIME_NOW) {
if ($suspensions[null][Suspension::TYPE_BAN]->time > TIME_NOW) {
$canEnter = false;
}
}
@ -75,14 +75,14 @@ public function canWrite(\wcf\data\user\User $user = null) {
$canWrite = $ph->getPermission($this, 'user.canWrite');
// room suspension
if ($canWrite && isset($suspensions[$this->roomID][Suspension::TYPE_MUTE])) {
if ($suspensions[$this->roomID][Suspension::TYPE_MUTE]['time'] > TIME_NOW) {
if ($suspensions[$this->roomID][Suspension::TYPE_MUTE]->time > TIME_NOW) {
$canWrite = false;
}
}
// global suspension
if ($canWrite && isset($suspensions[null][Suspension::TYPE_MUTE])) {
if ($suspensions[null][Suspension::TYPE_MUTE]['time'] > TIME_NOW) {
if ($suspensions[null][Suspension::TYPE_MUTE]->time > TIME_NOW) {
$canWrite = false;
}
}

View File

@ -28,6 +28,7 @@ class Suspension extends \chat\data\CHATDatabaseObject {
public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser();
$suspensions = \chat\util\ChatUtil::readUserData('suspensions', $user);
if ($suspensions === null) {
$sql = "SELECT
*
@ -40,8 +41,8 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
$stmt->execute(array($user->userID, TIME_NOW));
$suspensions = array();
while ($row = $stmt->fetchArray()) {
$suspensions[$row['roomID']][$row['type']] = $row;
while ($suspension = $stmt->fetchObject('\chat\data\suspension\Suspension')) {
$suspensions[$suspension->roomID][$suspension->type] = $suspension;
}
\chat\util\ChatUtil::writeUserData(array('suspensions' => $suspensions), $user);

View File

@ -31,7 +31,8 @@ public function prune() {
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute(array(TIME_NOW));
$objectIDs = array();
while ($objectIDs[] = $stmt->fetchColumn());
while ($objectID = $stmt->fetchColumn()) $objectIDs[] = $objectID;
return call_user_func(array($this->className, 'deleteAll'), $objectIDs);
}

View File

@ -3,6 +3,7 @@
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
use \wcf\util\DateUtil;
use \wcf\util\StringUtil;
/**
@ -42,6 +43,16 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
$this->lines[WCF::getLanguage()->get('wcf.chat.room')] = $room->getTitle();
}
// Suspensions
// TODO: Permissions
$suspensions = \chat\data\suspension\Suspension::getSuspensionsForUser($this->user);
foreach ($suspensions as $roomSuspensions) {
foreach ($roomSuspensions as $typeSuspension) {
$dateTime = DateUtil::getDateTimeByTimestamp($typeSuspension->time);
$this->lines[$typeSuspension->type.'-'.$typeSuspension->roomID] = str_replace('%time%', DateUtil::format($dateTime, DateUtil::TIME_FORMAT), str_replace('%date%', DateUtil::format($dateTime, DateUtil::DATE_FORMAT), WCF::getLanguage()->get('wcf.date.dateTimeFormat')));
}
}
// ip address
if (WCF::getSession()->getPermission('admin.user.canViewIpAddress')) {
$session = $this->fetchSession();