1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Implement maxUsers in RoomAction

This commit is contained in:
Maximilian Mader 2015-01-10 00:47:08 +01:00
parent f5edd74642
commit 48976d793b

View File

@ -147,6 +147,7 @@ public function getRoomList() {
'roomID' => (int) $room->roomID,
'active' => $this->parameters['room'] && $room->roomID == $this->parameters['room']->roomID,
'userCount' => count($room->getUsers()),
'maxUsers' => (int) $room->maxUsers,
'permissions' => array(
'canBan' => (boolean) $room->canBan(),
'canMute' => (boolean) $room->canMute()
@ -169,6 +170,12 @@ public function validateJoin() {
$room = RoomCache::getInstance()->getRoom($this->parameters['roomID']);
if ($room === null) throw new exception\UserInputException('roomID');
if (!$room->canEnter()) throw new exception\PermissionDeniedException();
if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers) {
$errorMessage = WCF::getLanguage()->getDynamicVariable('chat.global.error.join.full', array('room' => $room));
throw new exception\UserInputException('room', $errorMessage);
}
}
/**
@ -260,6 +267,7 @@ public function join() {
)),
'roomID' => (int) $room->roomID,
'userCount' => count($room->getUsers()),
'maxUsers' => (int) $room->maxUsers,
'permissions' => array(
'canBan' => (boolean) $room->canBan(),
'canMute' => (boolean) $room->canMute()