1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Clean up :)

This commit is contained in:
Tim Düsterhus 2013-05-18 22:05:03 +02:00
parent 22e6b6ea29
commit cdb8ad0c2d
4 changed files with 18 additions and 10 deletions

View File

@ -25,6 +25,12 @@ class Suspension extends \chat\data\CHATDatabaseObject {
const TYPE_MUTE = 1; const TYPE_MUTE = 1;
const TYPE_BAN = 2; const TYPE_BAN = 2;
/**
* Returns all the suspensions for the specified user (current user if no user was specified).
*
* @param \wcf\data\user\User $user
* @return array
*/
public static function getSuspensionsForUser(\wcf\data\user\User $user = null) { public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser(); if ($user === null) $user = WCF::getUser();
$suspensions = \chat\util\ChatUtil::readUserData('suspensions', $user); $suspensions = \chat\util\ChatUtil::readUserData('suspensions', $user);
@ -53,6 +59,7 @@ public static function getSuspensionsForUser(\wcf\data\user\User $user = null) {
/** /**
* Returns the appropriate suspension for user, room and type. * Returns the appropriate suspension for user, room and type.
* Returns false if no suspension was found.
* *
* @param \wcf\data\user\User $user * @param \wcf\data\user\User $user
* @param \chat\data\room\Room $room * @param \chat\data\room\Room $room
@ -78,7 +85,7 @@ public static function getSuspensionByUserRoomAndType(\wcf\data\user\User $user,
$statement = WCF::getDB()->prepareStatement($sql); $statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($parameter); $statement->execute($parameter);
$row = $statement->fetchArray(); $row = $statement->fetchArray();
if(!$row) $row = array(); if (!$row) return false;
return new self(null, $row); return new self(null, $row);
} }

View File

@ -23,8 +23,9 @@ class InfoCommand extends \chat\system\command\AbstractCommand {
public function __construct(\chat\system\command\CommandHandler $commandHandler) { public function __construct(\chat\system\command\CommandHandler $commandHandler) {
parent::__construct($commandHandler); parent::__construct($commandHandler);
$this->user = User::getUserByUsername(rtrim($commandHandler->getParameters(), ',')); $username = rtrim($commandHandler->getParameters(), ',');
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException(rtrim($commandHandler->getParameters(), ',')); $this->user = User::getUserByUsername($username);
if (!$this->user->userID) throw new \chat\system\command\UserNotFoundException($username);
// Username + link to profile // Username + link to profile
$profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array( $profile = \wcf\system\request\LinkHandler::getInstance()->getLink('User', array(
@ -40,7 +41,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
// Room // Room
$room = new \chat\data\room\Room(ChatUtil::readUserData('roomID', $this->user)); $room = new \chat\data\room\Room(ChatUtil::readUserData('roomID', $this->user));
if ($room->roomID && $room->canEnter()) { if ($room->roomID && $room->canEnter()) {
$this->lines[WCF::getLanguage()->get('wcf.chat.room')] = $room->getTitle(); $this->lines[WCF::getLanguage()->get('chat.general.room')] = $room->getTitle();
} }
// Suspensions // Suspensions

View File

@ -1,9 +1,9 @@
<?php <?php
namespace chat\system\command\commands; namespace chat\system\command\commands;
use \chat\data\suspension; use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User; use \wcf\data\user\User;
use \wcf\system\WCF; use \wcf\system\WCF;
use \chat\util\ChatUtil;
/** /**
* Mutes a user. * Mutes a user.
@ -52,8 +52,8 @@ public function executeAction() {
throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists')); throw new \wcf\system\exception\UserInputException('text', WCF::getLanguage()->get('wcf.chat.suspension.exists'));
} }
$editor = new suspension\SuspensionEditor($suspension); $action = new suspension\SuspensionAction(array($suspension), 'delete');
$editor->delete(); $action->executeAction();
} }
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array( $this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(

View File

@ -4,7 +4,6 @@
<item name="chat.acp.room.list"><![CDATA[Chaträume]]></item> <item name="chat.acp.room.list"><![CDATA[Chaträume]]></item>
<item name="chat.acp.room.add"><![CDATA[Chatraum hinzufügen]]></item> <item name="chat.acp.room.add"><![CDATA[Chatraum hinzufügen]]></item>
<item name="chat.acp.room.edit"><![CDATA[Chatraum bearbeiten]]></item> <item name="chat.acp.room.edit"><![CDATA[Chatraum bearbeiten]]></item>
<item name="chat.acp.room.data"><![CDATA[Daten des Raumes]]></item>
<item name="chat.acp.room.title"><![CDATA[Titel]]></item> <item name="chat.acp.room.title"><![CDATA[Titel]]></item>
<item name="chat.acp.room.topic"><![CDATA[Thema]]></item> <item name="chat.acp.room.topic"><![CDATA[Thema]]></item>
@ -64,8 +63,8 @@
<item name="chat.general.title"><![CDATA[Chat]]></item> <item name="chat.general.title"><![CDATA[Chat]]></item>
<item name="chat.general.protocol"><![CDATA[Protokoll]]></item> <item name="chat.general.protocol"><![CDATA[Protokoll]]></item>
<item name="chat.general.room"><![CDATA[Raum]]></item> <item name="chat.general.room"><![CDATA[Chatraum]]></item>
<item name="chat.general.rooms"><![CDATA[Räume]]></item> <item name="chat.general.rooms"><![CDATA[Chaträume]]></item>
<item name="chat.general.users"><![CDATA[Nutzer]]></item> <item name="chat.general.users"><![CDATA[Nutzer]]></item>
<item name="chat.general.copyright"><![CDATA[<a href="http://tims.bastelstu.be"><strong>Tims Chat</strong>{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}, entwickelt in <strong>Tims Bastelstube</strong></a>]]></item> <item name="chat.general.copyright"><![CDATA[<a href="http://tims.bastelstu.be"><strong>Tims Chat</strong>{if SHOW_VERSION_NUMBER} {PACKAGE_VERSION}{/if}, entwickelt in <strong>Tims Bastelstube</strong></a>]]></item>
@ -113,6 +112,7 @@
<item name="chat.message.5.ban"><![CDATA[hat {@$link} bis {@$until|plainTime} gebannt.]]></item> <item name="chat.message.5.ban"><![CDATA[hat {@$link} bis {@$until|plainTime} gebannt.]]></item>
<item name="chat.message.5.gmute"><![CDATA[hat {@$link} bis {@$until|plainTime} global geknebelt.]]></item> <item name="chat.message.5.gmute"><![CDATA[hat {@$link} bis {@$until|plainTime} global geknebelt.]]></item>
<item name="chat.message.5.gban"><![CDATA[hat {@$link} bis {@$until|plainTime} global gebannt.]]></item> <item name="chat.message.5.gban"><![CDATA[hat {@$link} bis {@$until|plainTime} global gebannt.]]></item>
<item name="chat.message.5.unmute"><![CDATA[hat {@$link} entknebelt.]]></item>
<item name="chat.message.color.success"><![CDATA[Die Farbe wurde erfolgreich geändert.]]></item> <item name="chat.message.color.success"><![CDATA[Die Farbe wurde erfolgreich geändert.]]></item>
</category> </category>