diff --git a/acptemplate/roomAdd.tpl b/acptemplate/roomAdd.tpl index 0946c98..7414a6c 100644 --- a/acptemplate/roomAdd.tpl +++ b/acptemplate/roomAdd.tpl @@ -71,6 +71,22 @@ {include file='multipleLanguageInputJavascript' elementIdentifier='topic' forceSelection=false} +
#{data.returnValues.errorType}
").wcfDialog + title: WCF.Language.get 'wcf.global.error.title' + + do $('#timsChatInput').enable().focus + do refreshRoomList + else + showError WCF.Language.get 'chat.error.join', data after: -> isJoining = no diff --git a/file/lib/acp/form/RoomAddForm.class.php b/file/lib/acp/form/RoomAddForm.class.php index 76f3c56..f875891 100644 --- a/file/lib/acp/form/RoomAddForm.class.php +++ b/file/lib/acp/form/RoomAddForm.class.php @@ -38,6 +38,13 @@ class RoomAddForm extends \wcf\form\AbstractForm { */ public $topic = ''; + /** + * Maximum number of users + * + * @var integer + */ + public $maxUsers = 0; + /** * @see \wcf\page\AbstractPage::__construct() */ @@ -67,6 +74,7 @@ public function readFormParameters() { if (I18nHandler::getInstance()->isPlainValue('title')) $this->title = I18nHandler::getInstance()->getValue('title'); if (I18nHandler::getInstance()->isPlainValue('topic')) $this->topic = I18nHandler::getInstance()->getValue('topic'); + if (isset($_POST['maxUsers']) $this->maxUsers = intval($_POST['maxUsers']); } /** @@ -90,7 +98,8 @@ public function save() { // save room $this->objectAction = new \chat\data\room\RoomAction(array(), 'create', array('data' => array_merge($this->additionalFields, array( 'title' => $this->title, - 'topic' => $this->topic + 'topic' => $this->topic, + 'maxUsers' => $this->maxUsers )))); $this->objectAction->executeAction(); $returnValues = $this->objectAction->getReturnValues(); @@ -116,7 +125,7 @@ public function save() { } \wcf\system\acl\ACLHandler::getInstance()->save($roomID, $this->objectTypeID); - \wcf\system\acl\ACLHandler::getInstance()->disableAssignVariables(); + \wcf\system\acl\ACLHandler::getInstance()->disableAssignVariables(); \chat\system\permission\PermissionHandler::clearCache(); $this->saved(); @@ -144,6 +153,7 @@ public function assignVariables() { 'action' => 'add', 'title' => $this->title, 'topic' => $this->topic, + 'maxUsers' => $this->maxUsers, 'objectTypeID' => $this->objectTypeID )); } diff --git a/file/lib/acp/form/RoomEditForm.class.php b/file/lib/acp/form/RoomEditForm.class.php index 44381b3..f8aa15e 100644 --- a/file/lib/acp/form/RoomEditForm.class.php +++ b/file/lib/acp/form/RoomEditForm.class.php @@ -83,13 +83,14 @@ public function save() { } \wcf\system\acl\ACLHandler::getInstance()->save($this->roomID, $this->objectTypeID); - \wcf\system\acl\ACLHandler::getInstance()->disableAssignVariables(); + \wcf\system\acl\ACLHandler::getInstance()->disableAssignVariables(); \chat\system\permission\PermissionHandler::clearCache(); // update room $this->objectAction = new \chat\data\room\RoomAction(array($this->roomID), 'update', array('data' => array_merge($this->additionalFields, array( 'title' => $this->title, - 'topic' => $this->topic + 'topic' => $this->topic, + 'maxUsers' => $this->maxUsers )))); $this->objectAction->executeAction(); @@ -113,6 +114,7 @@ public function readData() { $this->title = $this->roomObj->title; $this->topic = $this->roomObj->topic; + $this->maxUsers = $this->roomObj->maxUsers; } } diff --git a/file/lib/data/room/RoomAction.class.php b/file/lib/data/room/RoomAction.class.php index 8ba22aa..dd9e4bd 100644 --- a/file/lib/data/room/RoomAction.class.php +++ b/file/lib/data/room/RoomAction.class.php @@ -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() diff --git a/install.sql b/install.sql index 66d416b..91df76c 100644 --- a/install.sql +++ b/install.sql @@ -38,6 +38,7 @@ CREATE TABLE chat1_room ( showOrder INT(10) NOT NULL DEFAULT 0, permanent TINYINT(1) NOT NULL DEFAULT 1, owner INT(10) DEFAULT NULL, + maxUsers INT(10) NOT NULL DEFAULT 0 KEY (showOrder), KEY (owner) diff --git a/language/de.xml b/language/de.xml index a432414..e2597a8 100644 --- a/language/de.xml +++ b/language/de.xml @@ -161,6 +161,8 @@ Probieren Sie, den Chat neu zu laden