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

Validate room in form

This commit is contained in:
Tim Düsterhus 2011-12-26 17:07:46 +01:00
parent d2670d47c3
commit f2930612d1

View File

@ -16,8 +16,9 @@
* @subpackage form
*/
class ChatForm extends AbstractForm {
public $message = '';
public $enableSmilies = 1;
public $message = '';
public $room = null;
public $userData = array();
public $useTemplate = false;
@ -28,6 +29,10 @@ public function readData() {
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
$this->userData['roomID'] = \wcf\util\ChatUtil::readUserData('roomID');
$this->room = chat\room\ChatRoom::getCache()->search($this->userData['roomID']);
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
parent::readData();
}
@ -49,9 +54,6 @@ public function validate() {
if ($this->message === '') {
throw new UserInputException('text');
}
if ($this->userData['roomID'] === null) {
throw new PermissionDeniedException();
}
}
/**
@ -64,7 +66,7 @@ public function save() {
var_dump($commandHandler->isCommand($this->message));
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
'data' => array(
'roomID' => $this->userData['roomID'],
'roomID' => $this->room->roomID,
'sender' => WCF::getUser()->userID,
'username' => WCF::getUser()->username,
'time' => TIME_NOW,