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

Fix several class references and check permission in InfoCommand

This commit is contained in:
Tim Düsterhus 2013-01-27 21:58:10 +01:00
parent 9440e1a872
commit 8770affe56
13 changed files with 40 additions and 39 deletions

View File

@ -26,7 +26,7 @@ final class Update {
private $styles = null;
public function __construct() {
$this->rooms = \wcf\data\chat\room\ChatRoom::getCache();
$this->rooms = \chat\data\room\Room::getCache();
$this->styles = \wcf\system\style\StyleHandler::getInstance()->getAvailableStyles();
}
@ -36,11 +36,11 @@ public function __construct() {
*/
public function execute() {
foreach ($this->rooms as $room) {
$messageAction = new \wcf\data\chat\message\ChatMessageAction(array(), 'create', array(
$messageAction = new \chat\data\message\MessageAction(array(), 'create', array(
'data' => array(
'roomID' => $room->roomID,
'time' => TIME_NOW,
'type' => \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION,
'type' => \chat\data\message\Message::TYPE_INFORMATION,
'message' => \wcf\system\WCF::getLanguage()->get('wcf.chat.information.chatUpdate')
)
));

View File

@ -1,8 +1,8 @@
<?php
namespace chat\data\message;
use \chat\util\ChatUtil;
use \wcf\system\Regex;
use \wcf\system\WCF;
use \wcf\util\ChatUtil;
/**
* Represents a chat message.

View File

@ -23,7 +23,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_AWAY;
return \chat\data\message\Message::TYPE_AWAY;
}
/**

View File

@ -1,9 +1,9 @@
<?php
namespace chat\system\command\commands;
use \wcf\data\chat\suspension;
use \chat\data\suspension;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
use \wcf\util\ChatUtil;
/**
* Bans a user.
@ -16,21 +16,21 @@
*/
class BanCommand extends MuteCommand {
public function executeAction() {
if ($suspension = suspension\ChatSuspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\ChatSuspension::TYPE_BAN)) {
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_BAN)) {
if ($suspension->time > TIME_NOW + $this->time) {
$this->fail = true;
return;
}
$editor = new suspension\ChatSuspensionEditor($suspension);
$editor = new suspension\SuspensionEditor($suspension);
$editor->delete();
}
$this->suspensionAction = new suspension\ChatSuspensionAction(array(), 'create', array(
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => ChatUtil::readUserData('roomID'),
'type' => suspension\ChatSuspension::TYPE_BAN,
'type' => suspension\Suspension::TYPE_BAN,
'time' => TIME_NOW + $this->time
)
));

View File

@ -64,7 +64,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
return \chat\data\message\Message::TYPE_INFORMATION;
}
/**

View File

@ -1,8 +1,8 @@
<?php
namespace chat\system\command\commands;
use \chat\util\ChatUtil;
use \wcf\data\user\User;
use \wcf\system\WCF;
use \wcf\util\ChatUtil;
use \wcf\util\StringUtil;
/**
@ -39,16 +39,17 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
}
// Room
$room = new \wcf\data\chat\room\ChatRoom(ChatUtil::readUserData('roomID', $this->user));
$room = new \chat\data\room\Room(ChatUtil::readUserData('roomID', $this->user));
if ($room->roomID && $room->canEnter()) {
$this->lines[WCF::getLanguage()->get('wcf.chat.room')] = $room->getTitle();
}
// IP-Address
$session = $this->fetchSession();
if ($session) {
// TODO: Check permission
$this->lines[WCF::getLanguage()->get('wcf.user.ipAddress')] = $session->ipAddress;
// ip address
if (WCF::getSession()->getPermission('admin.user.canViewIpAddress')) {
$session = $this->fetchSession();
if ($session) {
$this->lines[WCF::getLanguage()->get('wcf.user.ipAddress')] = $session->ipAddress;
}
}
$this->didInit();
@ -78,7 +79,7 @@ public function fetchSession() {
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
return \chat\data\message\Message::TYPE_INFORMATION;
}
/**

View File

@ -24,7 +24,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_ME;
return \chat\data\message\Message::TYPE_ME;
}
/**

View File

@ -1,9 +1,9 @@
<?php
namespace chat\system\command\commands;
use \wcf\data\chat\suspension;
use \chat\data\suspension;
use \wcf\data\user\User;
use \wcf\system\WCF;
use \wcf\util\ChatUtil;
use \chat\util\ChatUtil;
/**
* Mutes a user.
@ -49,21 +49,21 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
}
public function executeAction() {
if ($suspension = suspension\ChatSuspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\ChatSuspension::TYPE_MUTE)) {
if ($suspension = suspension\Suspension::getSuspensionByUserRoomAndType($this->user, $this->room, suspension\Suspension::TYPE_MUTE)) {
if ($suspension->time > TIME_NOW + $this->time) {
$this->fail = true;
return;
}
$editor = new suspension\ChatSuspensionEditor($suspension);
$editor = new suspension\SuspensionEditor($suspension);
$editor->delete();
}
$this->suspensionAction = new suspension\ChatSuspensionAction(array(), 'create', array(
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
'data' => array(
'userID' => $this->user->userID,
'roomID' => ChatUtil::readUserData('roomID'),
'type' => suspension\ChatSuspension::TYPE_MUTE,
'type' => suspension\Suspension::TYPE_MUTE,
'time' => TIME_NOW + $this->time
)
));
@ -77,7 +77,7 @@ public function checkPermission() {
parent::checkPermission();
$this->room = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->request->room;
$ph = new \wcf\system\chat\permission\ChatPermissionHandler();
$ph = new \chat\system\permission\PermissionHandler();
if (!$ph->getPermission($this->room, 'mod.can'.str_replace(array('chat\system\command\commands\\', 'Command'), '', get_class($this)))) throw new \wcf\system\exception\PermissionDeniedException();
}
@ -94,8 +94,8 @@ public function getReceiver() {
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
if ($this->fail) return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
return \wcf\data\chat\message\ChatMessage::TYPE_MODERATE;
if ($this->fail) return \chat\data\message\Message::TYPE_INFORMATION;
return \chat\data\message\Message::TYPE_MODERATE;
}
/**

View File

@ -17,7 +17,7 @@ class PlainCommand extends \chat\system\command\AbstractCommand {
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_NORMAL;
return \chat\data\message\Message::TYPE_NORMAL;
}
/**

View File

@ -42,7 +42,7 @@ public function checkPermission() {
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_MODERATE;
return \chat\data\message\Message::TYPE_MODERATE;
}
/**

View File

@ -19,7 +19,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
parent::__construct($commandHandler);
// create room
$this->objectAction = new \wcf\data\chat\room\ChatRoomAction(array(), 'create', array('data' => array(
$this->objectAction = new \chat\data\room\RoomAction(array(), 'create', array('data' => array(
'title' => 'Temproom',
'topic' => '',
'permanent' => 0,
@ -27,7 +27,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
)));
$this->objectAction->executeAction();
$returnValues = $this->objectAction->getReturnValues();
$chatRoomEditor = new \wcf\data\chat\room\ChatRoomEditor($returnValues['returnValues']);
$chatRoomEditor = new \chat\data\room\RoomEditor($returnValues['returnValues']);
$roomID = $returnValues['returnValues']->roomID;
$this->roomName = WCF::getLanguage()->getDynamicVariable('wcf.chat.room.titleTemp', array('roomID' => $roomID));
@ -50,7 +50,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
);
\wcf\system\acl\ACLHandler::getInstance()->save($roomID, \wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('be.bastelstu.chat.room'));
\wcf\system\chat\permission\ChatPermissionHandler::clearCache();
\chat\system\permission\PermissionHandler::clearCache();
$this->didInit();
}
@ -67,7 +67,7 @@ public function checkPermission() {
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
return \chat\data\message\Message::TYPE_INFORMATION;
}
/**

View File

@ -18,14 +18,14 @@ class WhereCommand extends \chat\system\command\AbstractCommand {
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
return \chat\data\message\Message::TYPE_INFORMATION;
}
/**
* @see \chat\system\command\ICommand::getMessage()
*/
public function getMessage() {
$rooms = \wcf\data\chat\room\ChatRoom::getCache();
$rooms = \chat\data\room\Room::getCache();
foreach ($rooms as $room) {
$users = $room->getUsers();

View File

@ -36,7 +36,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
* @see \chat\system\command\ICommand::getType()
*/
public function getType() {
return \wcf\data\chat\message\ChatMessage::TYPE_WHISPER;
return \chat\data\message\Message::TYPE_WHISPER;
}
/**