diff --git a/acptemplate/chatRoomAdd.tpl b/acptemplate/chatRoomAdd.tpl
new file mode 100644
index 0000000..15053c3
--- /dev/null
+++ b/acptemplate/chatRoomAdd.tpl
@@ -0,0 +1,77 @@
+{include file='header'}
+
+
+
+
+ {lang}wcf.acp.chat.room.{$action}{/lang}
+
+
+
+{if $errorField}
+
{lang}wcf.global.form.error{/lang}
+{/if}
+
+{if $success|isset}
+ {lang}wcf.global.form.{$action}.success{/lang}
+{/if}
+
+
+
+
+
+{include file='footer'}
\ No newline at end of file
diff --git a/file/lib/acp/form/ChatRoomAddForm.class.php b/file/lib/acp/form/ChatRoomAddForm.class.php
new file mode 100644
index 0000000..d83cf47
--- /dev/null
+++ b/file/lib/acp/form/ChatRoomAddForm.class.php
@@ -0,0 +1,152 @@
+
+ * @package timwolla.wcf.chat
+ * @subpackage acp.form
+ */
+class ChatRoomAddForm extends ACPForm {
+ /**
+ * @see wcf\acp\form\ACPForm::$activeMenuItem
+ */
+ public $activeMenuItem = 'wcf.acp.menu.link.chat.room.add';
+
+ /**
+ * @see wcf\page\AbstractPage::$neededPermissions
+ */
+ public $neededPermissions = array('admin.content.chat.canAddRoom');
+
+ /**
+ * Title of the room
+ *
+ * @var string
+ */
+ public $title = '';
+
+ /**
+ * Topic of the room
+ *
+ * @var string
+ */
+ public $topic = '';
+
+ /**
+ * @see wcf\page\IPage::readParameters()
+ */
+ public function readParameters() {
+ parent::readParameters();
+
+ I18nHandler::getInstance()->register('title');
+ I18nHandler::getInstance()->register('topic');
+ }
+
+ /**
+ * @see wcf\form\IForm::readFormParameters()
+ */
+ public function readFormParameters() {
+ parent::readFormParameters();
+
+ I18nHandler::getInstance()->readValues();
+
+ if (I18nHandler::getInstance()->isPlainValue('title')) $this->title = I18nHandler::getInstance()->getValue('title');
+ if (I18nHandler::getInstance()->isPlainValue('topic')) $this->topic = I18nHandler::getInstance()->getValue('topic');
+ }
+
+ /**
+ * @see wcf\form\IForm::validate()
+ */
+ public function validate() {
+ parent::validate();
+
+ // validate title
+ try {
+ if (!I18nHandler::getInstance()->validateValue('title')) {
+ throw new UserInputException('title');
+ }
+ }
+ catch (UserInputException $e) {
+ $this->errorType[$e->getField()] = $e->getType();
+ }
+
+ // validate topic
+ try {
+ if (!I18nHandler::getInstance()->validateValue('topic')) {
+ throw new UserInputException('topic');
+ }
+ }
+ catch (UserInputException $e) {
+ $this->errorType[$e->getField()] = $e->getType();
+ }
+ }
+
+ /**
+ * @see wcf\form\IForm::save()
+ */
+ public function save() {
+ parent::save();
+
+ // save room
+ $chatRoomAction = new \wcf\data\chat\room\ChatRoomAction(array(), 'create', array('data' => array(
+ 'title' => $this->title,
+ 'topic' => $this->topic
+ )));
+ $chatRoomAction->executeAction();
+ $returnValues = $chatRoomAction->getReturnValues();
+ $chatRoomEditor = new \wcf\data\chat\room\ChatRoomEditor($returnValues['returnValues']);
+ $roomID = $returnValues['returnValues']->roomID;
+
+ if (!I18nHandler::getInstance()->isPlainValue('title')) {
+ I18nHandler::getInstance()->save('title', 'wcf.chat.room.title.room'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat'));
+
+ // update title
+
+ $chatRoomEditor->update(array(
+ 'title' => 'wcf.chat.room.title.room'.$roomID
+ ));
+ }
+
+ if (!I18nHandler::getInstance()->isPlainValue('topic')) {
+ I18nHandler::getInstance()->save('title', 'wcf.chat.room.topic.room'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat'));
+
+ // update topic
+ $chatRoomEditor->update(array(
+ 'title' => 'wcf.chat.room.topic.room'.$roomID
+ ));
+ }
+
+ $this->saved();
+
+ // reset values
+ $this->topic = $this->title = '';
+ I18nHandler::getInstance()->disableAssignValueVariables();
+
+ // show success
+ WCF::getTPL()->assign(array(
+ 'success' => true
+ ));
+ }
+
+ /**
+ * @see wcf\page\IPage::assignVariables()
+ */
+ public function assignVariables() {
+ parent::assignVariables();
+
+ I18nHandler::getInstance()->assignVariables();
+
+ WCF::getTPL()->assign(array(
+ 'action' => 'add',
+ 'title' => $this->title,
+ 'topic' => $this->topic
+ ));
+ }
+}
diff --git a/file/lib/data/chat/room/ChatRoomEditor.class.php b/file/lib/data/chat/room/ChatRoomEditor.class.php
index ee1a1a5..27eb607 100644
--- a/file/lib/data/chat/room/ChatRoomEditor.class.php
+++ b/file/lib/data/chat/room/ChatRoomEditor.class.php
@@ -1,5 +1,6 @@
clearResource('chatrooms');
}
+
+ /**
+ * @see \wcf\data\DatabaseObjectEditor::deleteAll()
+ */
+ public static function deleteAll(array $objectIDs = array()) {
+ parent::deleteAll($objectIDs);
+ $packageID = \wcf\system\package\PackageDependencyHandler::getPackageID('timwolla.wcf.chat');
+ $sql = "DELETE FROM wcf".WCF_N."_language_item
+ WHERE languageItem = ? AND packageID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+
+ WCF::getDB()->beginTransaction();
+ foreach ($objectIDs as $objectID) {
+ $statement->execute(array('wcf.chat.room.title.room'.$objectID, $packageID));
+ $statement->execute(array('wcf.chat.room.topic.room'.$objectID, $packageID));
+ }
+ WCF::getDB()->commitTransaction();
+
+ return count($objectIDs);
+ }
}
diff --git a/install.sql b/install.sql
index 21aa183..49f3823 100644
--- a/install.sql
+++ b/install.sql
@@ -21,7 +21,7 @@ CREATE TABLE wcf1_chat_message (
DROP TABLE IF EXISTS wcf1_chat_room;
CREATE TABLE wcf1_chat_room (
roomID int(10) NOT NULL AUTO_INCREMENT,
- title varchar(25) NOT NULL,
+ title varchar(255) NOT NULL,
topic varchar(255) NOT NULL,
position int(10) NOT NULL DEFAULT 0,
permanent tinyint(1) NOT NULL DEFAULT 1,
diff --git a/language/de.xml b/language/de.xml
index a4534f9..406da46 100644
--- a/language/de.xml
+++ b/language/de.xml
@@ -63,6 +63,9 @@
+
+
+
diff --git a/package.xml b/package.xml
index b701f61..3512887 100644
--- a/package.xml
+++ b/package.xml
@@ -5,7 +5,7 @@
0
1
- 3.0.0 Alpha 5
+ 3.0.0 Alpha 6
2011-11-26
com.woltlab.wcf.bbcode