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

Validate room first in MessageAction::send()

This commit is contained in:
Tim Düsterhus 2013-04-21 18:15:24 +02:00
parent ae2d02ae64
commit 7046452b58

View File

@ -44,6 +44,18 @@ public function prune() {
* Validates message sending.
*/
public function validateSend() {
// read user data
$this->parameters['userData']['color'] = \chat\util\ChatUtil::readUserData('color');
$this->parameters['userData']['roomID'] = \chat\util\ChatUtil::readUserData('roomID');
$this->parameters['userData']['away'] = \chat\util\ChatUtil::readUserData('away');
// read and validate room
$cache = room\Room::getCache();
if (!isset($cache[$this->parameters['userData']['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
$this->parameters['room'] = $cache[$this->parameters['userData']['roomID']];
if (!$this->parameters['room']->canEnter() || !$this->parameters['room']->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
// read parameters
$this->readString('text');
$this->readBoolean('enableSmilies');
@ -67,18 +79,6 @@ public function validateSend() {
}
}
// read user data
$this->parameters['userData']['color'] = \chat\util\ChatUtil::readUserData('color');
$this->parameters['userData']['roomID'] = \chat\util\ChatUtil::readUserData('roomID');
$this->parameters['userData']['away'] = \chat\util\ChatUtil::readUserData('away');
// read and validate room
$cache = room\Room::getCache();
if (!isset($cache[$this->parameters['userData']['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
$this->parameters['room'] = $cache[$this->parameters['userData']['roomID']];
if (!$this->parameters['room']->canEnter() || !$this->parameters['room']->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
\chat\util\ChatUtil::writeUserData(array('away' => null));
// mark user as back