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:
parent
9440e1a872
commit
8770affe56
@ -26,7 +26,7 @@ final class Update {
|
|||||||
private $styles = null;
|
private $styles = null;
|
||||||
|
|
||||||
public function __construct() {
|
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();
|
$this->styles = \wcf\system\style\StyleHandler::getInstance()->getAvailableStyles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,11 +36,11 @@ public function __construct() {
|
|||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
foreach ($this->rooms as $room) {
|
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(
|
'data' => array(
|
||||||
'roomID' => $room->roomID,
|
'roomID' => $room->roomID,
|
||||||
'time' => TIME_NOW,
|
'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')
|
'message' => \wcf\system\WCF::getLanguage()->get('wcf.chat.information.chatUpdate')
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace chat\data\message;
|
namespace chat\data\message;
|
||||||
|
use \chat\util\ChatUtil;
|
||||||
use \wcf\system\Regex;
|
use \wcf\system\Regex;
|
||||||
use \wcf\system\WCF;
|
use \wcf\system\WCF;
|
||||||
use \wcf\util\ChatUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chat message.
|
* Represents a chat message.
|
||||||
|
@ -23,7 +23,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_AWAY;
|
return \chat\data\message\Message::TYPE_AWAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace chat\system\command\commands;
|
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\data\user\User;
|
||||||
use \wcf\system\WCF;
|
use \wcf\system\WCF;
|
||||||
use \wcf\util\ChatUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bans a user.
|
* Bans a user.
|
||||||
@ -16,21 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
class BanCommand extends MuteCommand {
|
class BanCommand extends MuteCommand {
|
||||||
public function executeAction() {
|
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) {
|
if ($suspension->time > TIME_NOW + $this->time) {
|
||||||
$this->fail = true;
|
$this->fail = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = new suspension\ChatSuspensionEditor($suspension);
|
$editor = new suspension\SuspensionEditor($suspension);
|
||||||
$editor->delete();
|
$editor->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->suspensionAction = new suspension\ChatSuspensionAction(array(), 'create', array(
|
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
|
||||||
'data' => array(
|
'data' => array(
|
||||||
'userID' => $this->user->userID,
|
'userID' => $this->user->userID,
|
||||||
'roomID' => ChatUtil::readUserData('roomID'),
|
'roomID' => ChatUtil::readUserData('roomID'),
|
||||||
'type' => suspension\ChatSuspension::TYPE_BAN,
|
'type' => suspension\Suspension::TYPE_BAN,
|
||||||
'time' => TIME_NOW + $this->time
|
'time' => TIME_NOW + $this->time
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -64,7 +64,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
return \chat\data\message\Message::TYPE_INFORMATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace chat\system\command\commands;
|
namespace chat\system\command\commands;
|
||||||
|
use \chat\util\ChatUtil;
|
||||||
use \wcf\data\user\User;
|
use \wcf\data\user\User;
|
||||||
use \wcf\system\WCF;
|
use \wcf\system\WCF;
|
||||||
use \wcf\util\ChatUtil;
|
|
||||||
use \wcf\util\StringUtil;
|
use \wcf\util\StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,17 +39,18 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Room
|
// 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()) {
|
if ($room->roomID && $room->canEnter()) {
|
||||||
$this->lines[WCF::getLanguage()->get('wcf.chat.room')] = $room->getTitle();
|
$this->lines[WCF::getLanguage()->get('wcf.chat.room')] = $room->getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP-Address
|
// ip address
|
||||||
|
if (WCF::getSession()->getPermission('admin.user.canViewIpAddress')) {
|
||||||
$session = $this->fetchSession();
|
$session = $this->fetchSession();
|
||||||
if ($session) {
|
if ($session) {
|
||||||
// TODO: Check permission
|
|
||||||
$this->lines[WCF::getLanguage()->get('wcf.user.ipAddress')] = $session->ipAddress;
|
$this->lines[WCF::getLanguage()->get('wcf.user.ipAddress')] = $session->ipAddress;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->didInit();
|
$this->didInit();
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ public function fetchSession() {
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
return \chat\data\message\Message::TYPE_INFORMATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_ME;
|
return \chat\data\message\Message::TYPE_ME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace chat\system\command\commands;
|
namespace chat\system\command\commands;
|
||||||
use \wcf\data\chat\suspension;
|
use \chat\data\suspension;
|
||||||
use \wcf\data\user\User;
|
use \wcf\data\user\User;
|
||||||
use \wcf\system\WCF;
|
use \wcf\system\WCF;
|
||||||
use \wcf\util\ChatUtil;
|
use \chat\util\ChatUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes a user.
|
* Mutes a user.
|
||||||
@ -49,21 +49,21 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function executeAction() {
|
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) {
|
if ($suspension->time > TIME_NOW + $this->time) {
|
||||||
$this->fail = true;
|
$this->fail = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$editor = new suspension\ChatSuspensionEditor($suspension);
|
$editor = new suspension\SuspensionEditor($suspension);
|
||||||
$editor->delete();
|
$editor->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->suspensionAction = new suspension\ChatSuspensionAction(array(), 'create', array(
|
$this->suspensionAction = new suspension\SuspensionAction(array(), 'create', array(
|
||||||
'data' => array(
|
'data' => array(
|
||||||
'userID' => $this->user->userID,
|
'userID' => $this->user->userID,
|
||||||
'roomID' => ChatUtil::readUserData('roomID'),
|
'roomID' => ChatUtil::readUserData('roomID'),
|
||||||
'type' => suspension\ChatSuspension::TYPE_MUTE,
|
'type' => suspension\Suspension::TYPE_MUTE,
|
||||||
'time' => TIME_NOW + $this->time
|
'time' => TIME_NOW + $this->time
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
@ -77,7 +77,7 @@ public function checkPermission() {
|
|||||||
parent::checkPermission();
|
parent::checkPermission();
|
||||||
|
|
||||||
$this->room = \wcf\system\request\RequestHandler::getInstance()->getActiveRequest()->getRequestObject()->request->room;
|
$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();
|
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()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
if ($this->fail) return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
if ($this->fail) return \chat\data\message\Message::TYPE_INFORMATION;
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_MODERATE;
|
return \chat\data\message\Message::TYPE_MODERATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ class PlainCommand extends \chat\system\command\AbstractCommand {
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_NORMAL;
|
return \chat\data\message\Message::TYPE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +42,7 @@ public function checkPermission() {
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_MODERATE;
|
return \chat\data\message\Message::TYPE_MODERATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
parent::__construct($commandHandler);
|
parent::__construct($commandHandler);
|
||||||
|
|
||||||
// create room
|
// 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',
|
'title' => 'Temproom',
|
||||||
'topic' => '',
|
'topic' => '',
|
||||||
'permanent' => 0,
|
'permanent' => 0,
|
||||||
@ -27,7 +27,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
)));
|
)));
|
||||||
$this->objectAction->executeAction();
|
$this->objectAction->executeAction();
|
||||||
$returnValues = $this->objectAction->getReturnValues();
|
$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;
|
$roomID = $returnValues['returnValues']->roomID;
|
||||||
$this->roomName = WCF::getLanguage()->getDynamicVariable('wcf.chat.room.titleTemp', array('roomID' => $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\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();
|
$this->didInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public function checkPermission() {
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION;
|
return \chat\data\message\Message::TYPE_INFORMATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,14 +18,14 @@ class WhereCommand extends \chat\system\command\AbstractCommand {
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function 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()
|
* @see \chat\system\command\ICommand::getMessage()
|
||||||
*/
|
*/
|
||||||
public function getMessage() {
|
public function getMessage() {
|
||||||
$rooms = \wcf\data\chat\room\ChatRoom::getCache();
|
$rooms = \chat\data\room\Room::getCache();
|
||||||
|
|
||||||
foreach ($rooms as $room) {
|
foreach ($rooms as $room) {
|
||||||
$users = $room->getUsers();
|
$users = $room->getUsers();
|
||||||
|
@ -36,7 +36,7 @@ public function __construct(\chat\system\command\CommandHandler $commandHandler)
|
|||||||
* @see \chat\system\command\ICommand::getType()
|
* @see \chat\system\command\ICommand::getType()
|
||||||
*/
|
*/
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return \wcf\data\chat\message\ChatMessage::TYPE_WHISPER;
|
return \chat\data\message\Message::TYPE_WHISPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user