diff --git a/file/lib/data/room/Room.class.php b/file/lib/data/room/Room.class.php index 88ed8b8..ecf9af0 100644 --- a/file/lib/data/room/Room.class.php +++ b/file/lib/data/room/Room.class.php @@ -41,14 +41,14 @@ class Room extends \chat\data\CHATDatabaseObject implements \wcf\system\request\ public function __toString() { return $this->getTitle(); } - + /** - * Returns whether the user is allowed to enter the room. + * Returns whther the user is allowed to always enter the room. * * @param \wcf\data\user\User $user * @return boolean */ - public function canEnter(\wcf\data\user\User $user = null) { + public function canAlwaysEnter(\wcf\data\user\User $user = null) { if ($user === null) $user = WCF::getUser(); if (!$user->userID) return false; $user = new \wcf\data\user\UserProfile($user); @@ -59,7 +59,23 @@ public function canEnter(\wcf\data\user\User $user = null) { $ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject()); if ($ph->getPermission($this, 'mod.canAlwaysEnter')) return true; if ($ph->getPermission($this, 'mod.canBan')) return true; + + return false; + } + + /** + * Returns whether the user is allowed to enter the room. + * + * @param \wcf\data\user\User $user + * @return boolean + */ + public function canEnter(\wcf\data\user\User $user = null) { + if ($user === null) $user = WCF::getUser(); + if (!$user->userID) return false; + if ($this->canAlwaysEnter($user)) return true; + $user = new \wcf\data\user\UserProfile($user); + $ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject()); if (!$ph->getPermission($this, 'user.canEnter')) return false; $suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject()); diff --git a/file/lib/data/room/RoomAction.class.php b/file/lib/data/room/RoomAction.class.php index dd9e4bd..8181d0b 100644 --- a/file/lib/data/room/RoomAction.class.php +++ b/file/lib/data/room/RoomAction.class.php @@ -171,7 +171,7 @@ public function validateJoin() { if ($room === null) throw new exception\UserInputException('roomID'); if (!$room->canEnter()) throw new exception\PermissionDeniedException(); - if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers) { + if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers && !$room->canAlwaysEnter()) { $errorMessage = WCF::getLanguage()->getDynamicVariable('chat.global.error.join.full', array('room' => $room)); throw new exception\UserInputException('room', $errorMessage); diff --git a/template/chat.tpl b/template/chat.tpl index a19c90e..48b5dbc 100644 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -4,7 +4,7 @@ {if $room}{$room} - {/if}{lang}chat.global.title{/lang} - {PAGE_TITLE|language} {include file='headInclude'} - {if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers)} + {if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers || $room->canAlwaysEnter())} {include file='javascriptInclude' application='chat'}