diff --git a/acptemplate/chatRoomAdd.tpl b/acptemplate/chatRoomAdd.tpl index 2b03e96..615fe51 100644 --- a/acptemplate/chatRoomAdd.tpl +++ b/acptemplate/chatRoomAdd.tpl @@ -1,5 +1,24 @@ {include file='header'} + + + + + + +
@@ -63,6 +82,11 @@ {include file='multipleLanguageInputJavascript' elementIdentifier='topic'} + +
+
{lang}wcf.acp.acl.permissions{/lang}
+
+
diff --git a/file/js/TimWolla.WCF.Chat.coffee b/file/js/TimWolla.WCF.Chat.coffee index b570dc0..d2cb605 100644 --- a/file/js/TimWolla.WCF.Chat.coffee +++ b/file/js/TimWolla.WCF.Chat.coffee @@ -78,8 +78,9 @@ consoleMock ?= , @ # Unload the chat - $(window).unload $.proxy () -> + window.onbeforeunload = $.proxy () -> @unload() + return undefined , @ # Insert a smiley diff --git a/file/lib/acp/form/ChatRoomAddForm.class.php b/file/lib/acp/form/ChatRoomAddForm.class.php index 81bdd98..81d4c3f 100644 --- a/file/lib/acp/form/ChatRoomAddForm.class.php +++ b/file/lib/acp/form/ChatRoomAddForm.class.php @@ -8,7 +8,7 @@ /** * Shows the chatroom add form. * - * @author Tim Düsterhus + * @author Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat @@ -16,12 +16,12 @@ */ class ChatRoomAddForm extends ACPForm { /** - * @see \wcf\acp\form\ACPForm::$activeMenuItem + * @see \wcf\acp\form\ACPForm::$activeMenuItem */ public $activeMenuItem = 'wcf.acp.menu.link.chat.room.add'; /** - * @see \wcf\page\AbstractPage::$neededPermissions + * @see \wcf\page\AbstractPage::$neededPermissions */ public $neededPermissions = array('admin.content.chat.canAddRoom'); @@ -40,7 +40,16 @@ class ChatRoomAddForm extends ACPForm { public $topic = ''; /** - * @see wcf\page\IPage::readParameters() + * @see \wcf\page\AbstractPage::__construct() + */ + public function __construct() { + $this->objectTypeID = \wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('timwolla.wcf.chat.room'); + + parent::__construct(); + } + + /** + * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); @@ -50,7 +59,7 @@ public function readParameters() { } /** - * @see wcf\form\IForm::readFormParameters() + * @see \wcf\form\IForm::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); @@ -62,7 +71,7 @@ public function readFormParameters() { } /** - * @see wcf\form\IForm::validate() + * @see \wcf\form\IForm::validate() */ public function validate() { parent::validate(); @@ -74,7 +83,7 @@ public function validate() { } /** - * @see wcf\form\IForm::save() + * @see \wcf\form\IForm::save() */ public function save() { parent::save(); @@ -97,22 +106,25 @@ public function save() { 'title' => 'wcf.chat.room.title'.$roomID )); } - + if (!I18nHandler::getInstance()->isPlainValue('topic')) { I18nHandler::getInstance()->save('topic', 'wcf.chat.room.topic'.$roomID, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); - + // update topic $chatRoomEditor->update(array( 'topic' => 'wcf.chat.room.topic'.$roomID )); } - + + \wcf\system\acl\ACLHandler::getInstance()->save($roomID, $this->objectTypeID); + \wcf\system\chat\permissions\ChatPermissionHandler::clearCache(); + $this->saved(); - + // reset values $this->topic = $this->title = ''; I18nHandler::getInstance()->disableAssignValueVariables(); - + // show success WCF::getTPL()->assign(array( 'success' => true @@ -120,7 +132,7 @@ public function save() { } /** - * @see wcf\page\IPage::assignVariables() + * @see \wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); @@ -130,7 +142,8 @@ public function assignVariables() { WCF::getTPL()->assign(array( 'action' => 'add', 'title' => $this->title, - 'topic' => $this->topic + 'topic' => $this->topic, + 'objectTypeID' => $this->objectTypeID )); } } diff --git a/file/lib/acp/form/ChatRoomEditForm.class.php b/file/lib/acp/form/ChatRoomEditForm.class.php index e373fc5..a0298be 100644 --- a/file/lib/acp/form/ChatRoomEditForm.class.php +++ b/file/lib/acp/form/ChatRoomEditForm.class.php @@ -15,17 +15,17 @@ */ class ChatRoomEditForm extends ChatRoomAddForm { /** - * @see \wcf\page\AbstractPage::$templateName + * @see \wcf\page\AbstractPage::$templateName */ public $templateName = 'chatRoomAdd'; /** - * @see \wcf\acp\form\ACPForm::$activeMenuItem + * @see \wcf\acp\form\ACPForm::$activeMenuItem */ public $activeMenuItem = 'wcf.acp.menu.link.chat.room.list'; /** - * @see \wcf\page\AbstractPage::$neededPermissions + * @see \wcf\page\AbstractPage::$neededPermissions */ public $neededPermissions = array('admin.content.chat.canEditRoom'); @@ -44,7 +44,7 @@ class ChatRoomEditForm extends ChatRoomAddForm { public $roomObj = null; /** - * @see wcf\page\IPage::readParameters() + * @see \wcf\page\IPage::readParameters() */ public function readParameters() { parent::readParameters(); @@ -57,7 +57,7 @@ public function readParameters() { } /** - * @see wcf\form\IForm::save() + * @see \wcf\form\IForm::save() */ public function save() { ACPForm::save(); @@ -80,6 +80,8 @@ public function save() { I18nHandler::getInstance()->save('topic', $this->topic, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); } + \wcf\system\acl\ACLHandler::getInstance()->save($this->roomID, $this->objectTypeID); + \wcf\system\chat\permission\ChatPermissionHandler::clearCache(); // update room $this->objectAction = new \wcf\data\chat\room\ChatRoomAction(array($this->roomID), 'update', array('data' => array( @@ -97,7 +99,7 @@ public function save() { } /** - * @see wcf\page\IPage::readData() + * @see \wcf\page\IPage::readData() */ public function readData() { parent::readData(); @@ -112,7 +114,7 @@ public function readData() { } /** - * @see wcf\page\IPage::assignVariables() + * @see \wcf\page\IPage::assignVariables() */ public function assignVariables() { parent::assignVariables(); diff --git a/file/lib/acp/page/ChatRoomListPage.class.php b/file/lib/acp/page/ChatRoomListPage.class.php index efbe911..ac1314a 100644 --- a/file/lib/acp/page/ChatRoomListPage.class.php +++ b/file/lib/acp/page/ChatRoomListPage.class.php @@ -12,7 +12,7 @@ */ class ChatRoomListPage extends \wcf\page\MultipleLinkPage { /** - * @see wcf\page\AbstractPage::$neededPermissions + * @see \wcf\page\AbstractPage::$neededPermissions */ public $neededPermissions = array( 'admin.content.chat.canEditRoom', @@ -20,22 +20,22 @@ class ChatRoomListPage extends \wcf\page\MultipleLinkPage { ); /** - * @see wcf\page\MultipleLinkPage::$objectListClassName + * @see \wcf\page\MultipleLinkPage::$objectListClassName */ public $objectListClassName = '\wcf\data\chat\room\ChatRoomList'; /** - * @see wcf\page\MultipleLinkPage::$sortField + * @see \wcf\page\MultipleLinkPage::$sortField */ public $sortField = 'position'; /** - * @see wcf\page\MultipleLinkPage::$sortOrder + * @see \wcf\page\MultipleLinkPage::$sortOrder */ public $sortOrder = 'ASC'; /** - * @see wcf\page\IPage::show() + * @see \wcf\page\IPage::show() */ public function show() { // set active menu item. diff --git a/file/lib/action/ChatLeaveAction.class.php b/file/lib/action/ChatLeaveAction.class.php index 2058073..6a372a0 100644 --- a/file/lib/action/ChatLeaveAction.class.php +++ b/file/lib/action/ChatLeaveAction.class.php @@ -13,13 +13,16 @@ * @subpackage action */ class ChatLeaveAction extends AbstractAction { + /** + * @see \wcf\action\AbstractAction::$neededModules + */ public $neededModules = array('CHAT_ACTIVE'); //public $neededPermissions = array('user.chat.canEnter'); public $room = null; public $userData = array(); /** - * @see wcf\action\IAction::execute() + * @see \wcf\action\IAction::execute() */ public function execute() { parent::execute(); diff --git a/file/lib/data/chat/message/ChatMessage.class.php b/file/lib/data/chat/message/ChatMessage.class.php index f300148..32f7ecc 100755 --- a/file/lib/data/chat/message/ChatMessage.class.php +++ b/file/lib/data/chat/message/ChatMessage.class.php @@ -13,12 +13,12 @@ */ class ChatMessage extends \wcf\data\DatabaseObject { /** - * @see wcf\data\DatabaseObject::$databaseTableName + * @see \wcf\data\DatabaseObject::$databaseTableName */ protected static $databaseTableName = 'chat_message'; /** - * @see wcf\data\DatabaseObject::$databaseTableIndexName + * @see \wcf\data\DatabaseObject::$databaseTableIndexName */ protected static $databaseTableIndexName = 'messageID'; diff --git a/file/lib/data/chat/message/ChatMessageAction.class.php b/file/lib/data/chat/message/ChatMessageAction.class.php index 4d6d4ff..fef87e4 100644 --- a/file/lib/data/chat/message/ChatMessageAction.class.php +++ b/file/lib/data/chat/message/ChatMessageAction.class.php @@ -12,7 +12,7 @@ */ class ChatMessageAction extends \wcf\data\AbstractDatabaseObjectAction { /** - * @see wcf\data\AbstractDatabaseObjectAction::$className + * @see \wcf\data\AbstractDatabaseObjectAction::$className */ protected $className = '\wcf\data\chat\message\ChatMessageEditor'; } diff --git a/file/lib/data/chat/message/ChatMessageEditor.class.php b/file/lib/data/chat/message/ChatMessageEditor.class.php index abad314..ee54251 100644 --- a/file/lib/data/chat/message/ChatMessageEditor.class.php +++ b/file/lib/data/chat/message/ChatMessageEditor.class.php @@ -12,7 +12,7 @@ */ class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor { /** - * @see wcf\data\DatabaseObjectDecorator::$baseClass + * @see \wcf\data\DatabaseObjectDecorator::$baseClass */ protected static $baseClass = '\wcf\data\chat\message\ChatMessage'; diff --git a/file/lib/data/chat/message/ChatMessageList.class.php b/file/lib/data/chat/message/ChatMessageList.class.php index 2f3e01e..bb3853e 100644 --- a/file/lib/data/chat/message/ChatMessageList.class.php +++ b/file/lib/data/chat/message/ChatMessageList.class.php @@ -12,7 +12,7 @@ */ class ChatMessageList extends \wcf\data\DatabaseObjectList { /** - * @see wcf\data\DatabaseObjectList::$className + * @see \wcf\data\DatabaseObjectList::$className */ public $className = 'wcf\data\chat\message\ChatMessage'; diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php index 9193bf0..ee66354 100644 --- a/file/lib/data/chat/room/ChatRoom.class.php +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -13,12 +13,12 @@ */ class ChatRoom extends \wcf\data\DatabaseObject implements \wcf\system\request\IRouteController { /** - * @see wcf\data\DatabaseObject::$databaseTableName + * @see \wcf\data\DatabaseObject::$databaseTableName */ protected static $databaseTableName = 'chat_room'; /** - * @see wcf\data\DatabaseObject::$databaseTableIndexName + * @see \wcf\data\DatabaseObject::$databaseTableIndexName */ protected static $databaseTableIndexName = 'roomID'; @@ -76,6 +76,6 @@ public function getID() { * @return boolean */ public function canEnter() { - return \wcf\system\chat\permissions\ChatPermissionHandler::getInstance()->getPermission($this, 'canEnter'); + return \wcf\system\chat\permission\ChatPermissionHandler::getInstance()->getPermission($this, 'canEnter'); } } diff --git a/file/lib/data/chat/room/ChatRoomAction.class.php b/file/lib/data/chat/room/ChatRoomAction.class.php index 09f2a28..20be631 100644 --- a/file/lib/data/chat/room/ChatRoomAction.class.php +++ b/file/lib/data/chat/room/ChatRoomAction.class.php @@ -12,17 +12,17 @@ */ class ChatRoomAction extends \wcf\data\AbstractDatabaseObjectAction { /** - * @see wcf\data\AbstractDatabaseObjectAction::$className + * @see \wcf\data\AbstractDatabaseObjectAction::$className */ protected $className = '\wcf\data\chat\room\ChatRoomEditor'; /** - * @see wcf\data\AbstractDatabaseObjectAction::$permissionsDelete + * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete */ protected $permissionsDelete = array('admin.content.chat.canDeleteRoom'); /** - * @see wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate + * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate */ protected $permissionsUpdate = array('admin.content.chat.canEditRoom'); } diff --git a/file/lib/data/chat/room/ChatRoomEditor.class.php b/file/lib/data/chat/room/ChatRoomEditor.class.php index 6450070..01f2118 100644 --- a/file/lib/data/chat/room/ChatRoomEditor.class.php +++ b/file/lib/data/chat/room/ChatRoomEditor.class.php @@ -13,7 +13,7 @@ */ class ChatRoomEditor extends \wcf\data\DatabaseObjectEditor implements \wcf\data\IEditableCachedObject { /** - * @see wcf\data\DatabaseObjectDecorator::$baseClass + * @see \wcf\data\DatabaseObjectDecorator::$baseClass */ protected static $baseClass = '\wcf\data\chat\room\ChatRoom'; @@ -26,7 +26,7 @@ public static function resetCache() { } /** - * @see \wcf\data\DatabaseObjectEditor::deleteAll() + * @see \wcf\data\DatabaseObjectEditor::deleteAll() */ public static function deleteAll(array $objectIDs = array()) { parent::deleteAll($objectIDs); diff --git a/file/lib/data/chat/room/ChatRoomList.class.php b/file/lib/data/chat/room/ChatRoomList.class.php index 6a311d7..7e369be 100644 --- a/file/lib/data/chat/room/ChatRoomList.class.php +++ b/file/lib/data/chat/room/ChatRoomList.class.php @@ -12,7 +12,7 @@ */ class ChatRoomList extends \wcf\data\DatabaseObjectList { /** - * @see wcf\data\DatabaseObjectList::$className + * @see \wcf\data\DatabaseObjectList::$className */ public $className = 'wcf\data\chat\room\ChatRoom'; } diff --git a/file/lib/form/ChatForm.class.php b/file/lib/form/ChatForm.class.php index c3f34ca..9e7b129 100644 --- a/file/lib/form/ChatForm.class.php +++ b/file/lib/form/ChatForm.class.php @@ -7,8 +7,8 @@ /** * Inserts a message - * - * @author Tim Düsterhus + * + * @author Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus * @license Creative Commons Attribution-NonCommercial-ShareAlike * @package timwolla.wcf.chat @@ -19,6 +19,10 @@ class ChatForm extends AbstractForm { public $message = ''; public $room = null; public $userData = array(); + + /** + * @see \wcf\page\AbstractForm::$useTemplate + */ public $useTemplate = false; /** @@ -81,7 +85,7 @@ public function save() { } /** - * @see \wcf\page\IPage::show() + * @see \wcf\page\IPage::show() */ public function show() { header("HTTP/1.0 204 No Content"); diff --git a/file/lib/page/ChatMessagePage.class.php b/file/lib/page/ChatMessagePage.class.php index 106bd09..de5d9b3 100644 --- a/file/lib/page/ChatMessagePage.class.php +++ b/file/lib/page/ChatMessagePage.class.php @@ -22,7 +22,7 @@ class ChatMessagePage extends AbstractPage { public $useTemplate = false; /** - * @see \wcf\page\Page::readData() + * @see \wcf\page\Page::readData() */ public function readData() { parent::readData(); diff --git a/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php b/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php index c21267f..985d823 100644 --- a/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php +++ b/file/lib/system/cache/builder/ChatRoomCacheBuilder.class.php @@ -12,7 +12,7 @@ */ class ChatRoomCacheBuilder implements ICacheBuilder { /** - * @see wcf\system\cache\ICacheBuilder::getData() + * @see \wcf\system\cache\ICacheBuilder::getData() */ public function getData(array $cacheResource) { // get all chat rooms diff --git a/file/lib/system/chat/permissions/ChatPermissionHandler.class.php b/file/lib/system/chat/permission/ChatPermissionHandler.class.php similarity index 89% rename from file/lib/system/chat/permissions/ChatPermissionHandler.class.php rename to file/lib/system/chat/permission/ChatPermissionHandler.class.php index d525b9e..e125c56 100644 --- a/file/lib/system/chat/permissions/ChatPermissionHandler.class.php +++ b/file/lib/system/chat/permission/ChatPermissionHandler.class.php @@ -1,5 +1,5 @@ chatPermissions[$room->roomID][$permission])) return true; return (boolean) $this->chatPermissions[$room->roomID][$permission]; } + + /** + * Clears the cache. + */ + public static function clearCache() { + $packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); + $ush = \wcf\system\user\storage\UserStorageHandler::getInstance(); + + $ush->resetAll('chatUserPermissions', $packageID); + } } \ No newline at end of file diff --git a/file/lib/system/event/listener/ChatRouteListener.class.php b/file/lib/system/event/listener/ChatRouteListener.class.php index bfe11b1..7b6ee57 100644 --- a/file/lib/system/event/listener/ChatRouteListener.class.php +++ b/file/lib/system/event/listener/ChatRouteListener.class.php @@ -12,7 +12,7 @@ */ class ChatRouteListener implements \wcf\system\event\IEventListener { /** - * @see wcf\system\event\IEventListener::execute() + * @see \wcf\system\event\IEventListener::execute() */ public function execute($eventObj, $className, $eventName) { $route = new \wcf\system\request\Route('chatAction'); diff --git a/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php b/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php index 978c956..e38a136 100644 --- a/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php +++ b/file/lib/system/menu/page/ChatPageMenuItemProvider.class.php @@ -17,7 +17,7 @@ class ChatPageMenuItemProvider extends DefaultPageMenuItemProvider { /** * Hides the button when there is no valid room * - * @see \wcf\system\menu\page\PageMenuItemProvider::isVisible() + * @see \wcf\system\menu\page\PageMenuItemProvider::isVisible() */ public function isVisible() { // guests are not supported @@ -43,7 +43,7 @@ public function isVisible() { /** * Modifies the link to show the Link we would be redirect to. * - * @see \wcf\system\menu\page\PageMenuItemProvider::getLink() + * @see \wcf\system\menu\page\PageMenuItemProvider::getLink() */ public function getLink() { return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( diff --git a/file/lib/system/option/TimeIntervalOptionType.class.php b/file/lib/system/option/TimeIntervalOptionType.class.php index 7f35c22..68421af 100644 --- a/file/lib/system/option/TimeIntervalOptionType.class.php +++ b/file/lib/system/option/TimeIntervalOptionType.class.php @@ -12,14 +12,14 @@ */ class TimeIntervalOptionType extends TextOptionType { /** - * @see wcf\system\option\IOptionType::getData() + * @see \wcf\system\option\IOptionType::getData() */ public function getData(\wcf\data\option\Option $option, $newValue) { return \wcf\util\ChatUtil::timeModifier($newValue); } /** - * @see wcf\system\option\TextOptionType::getFormElement() + * @see \wcf\system\option\TextOptionType::getFormElement() */ public function getFormElement(\wcf\data\option\Option $option, $value) { $tmp = (int) ($value / 60);