diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php index 578c566..1d2d831 100644 --- a/file/lib/data/chat/room/ChatRoom.class.php +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -37,6 +37,29 @@ public function __toString() { return $this->getTitle(); } + + /** + * Returns whether the user is allowed to enter the room. + * + * @return boolean + */ + public function canEnter() { + $ph = \wcf\system\chat\permission\ChatPermissionHandler::getInstance(); + + return $ph->getPermission($this, 'user.canEnter') || $ph->getPermission($this, 'mod.canAlwaysEnter'); + } + + /** + * Returns whether the user is allowed to write messages in this room. + * + * @return boolean + */ + public function canWrite() { + $ph = \wcf\system\chat\permission\ChatPermissionHandler::getInstance(); + + return $ph->getPermission($this, 'user.canWrite') || $ph->getPermission($this, 'mod.canAlwaysWrite'); + } + /** * Returns the number of users currently active in this room. * @@ -136,15 +159,4 @@ public function getUsers() { return $stmt->fetchObjects('\wcf\data\user\User'); } - - /** - * Returns whether the user is allowed to enter the room - * - * @return boolean - */ - public function canEnter() { - $ph = \wcf\system\chat\permission\ChatPermissionHandler::getInstance(); - - return $ph->getPermission($this, 'user.canEnter') || $ph->getPermission($this, 'mod.canAlwaysEnter'); - } } diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index 2666574..cedde00 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -38,7 +38,7 @@ public function readData() { $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(); - + if (!$this->room->canWrite()) throw new \wcf\system\exception\PermissionDeniedException(); parent::readData(); }