1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2025-01-09 00:20:08 +00:00

Adding ACL-Administration

plus correcting comments and fixing unload handler
This commit is contained in:
Tim Düsterhus 2012-02-26 17:55:44 +01:00
parent 38977abbd8
commit dbd4e7b849
21 changed files with 111 additions and 54 deletions

View File

@ -1,5 +1,24 @@
{include file='header'} {include file='header'}
<!-- ToDo: DEBUG ONLY -->
<link rel="stylesheet" type="text/css" href="{@$__wcf->getPath('wcf')}style/acl.css" />
<!-- /DEBUG ONLY -->
<script type="text/javascript" src="{@$__wcf->getPath('wcf')}js/WCF.ACL.js"></script>
<script type="text/javascript">
//<![CDATA[
$(function() {
WCF.Icon.addObject({
'wcf.icon.delete': '{@$__wcf->getPath('wcf')}icon/delete1.svg',
'wcf.icon.user': '{@$__wcf->getPath('wcf')}icon/user1.svg',
'wcf.icon.users': '{@$__wcf->getPath('wcf')}icon/users1.svg'
});
new WCF.ACL.List($('#groupPermissions'), {@$objectTypeID}{if $groupID|isset}, {@$groupID}{/if});
});
//]]>
</script>
<header class="wcf-mainHeading"> <header class="wcf-mainHeading">
<img src="{@$__wcf->getPath('wcf')}icon/{$action}1.svg" alt="" /> <img src="{@$__wcf->getPath('wcf')}icon/{$action}1.svg" alt="" />
<hgroup> <hgroup>
@ -63,6 +82,11 @@
</dl> </dl>
{include file='multipleLanguageInputJavascript' elementIdentifier='topic'} {include file='multipleLanguageInputJavascript' elementIdentifier='topic'}
<dl id="groupPermissions">
<dt>{lang}wcf.acp.acl.permissions{/lang}</dt>
<dd></dd>
</dl>
</fieldset> </fieldset>
</div> </div>

View File

@ -78,8 +78,9 @@ consoleMock ?=
, @ , @
# Unload the chat # Unload the chat
$(window).unload $.proxy () -> window.onbeforeunload = $.proxy () ->
@unload() @unload()
return undefined
, @ , @
# Insert a smiley # Insert a smiley

View File

@ -8,7 +8,7 @@
/** /**
* Shows the chatroom add form. * Shows the chatroom add form.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2012 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
@ -16,12 +16,12 @@
*/ */
class ChatRoomAddForm extends ACPForm { 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'; 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'); public $neededPermissions = array('admin.content.chat.canAddRoom');
@ -40,7 +40,16 @@ class ChatRoomAddForm extends ACPForm {
public $topic = ''; 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() { public function readParameters() {
parent::readParameters(); parent::readParameters();
@ -50,7 +59,7 @@ public function readParameters() {
} }
/** /**
* @see wcf\form\IForm::readFormParameters() * @see \wcf\form\IForm::readFormParameters()
*/ */
public function readFormParameters() { public function readFormParameters() {
parent::readFormParameters(); parent::readFormParameters();
@ -62,7 +71,7 @@ public function readFormParameters() {
} }
/** /**
* @see wcf\form\IForm::validate() * @see \wcf\form\IForm::validate()
*/ */
public function validate() { public function validate() {
parent::validate(); parent::validate();
@ -74,7 +83,7 @@ public function validate() {
} }
/** /**
* @see wcf\form\IForm::save() * @see \wcf\form\IForm::save()
*/ */
public function save() { public function save() {
parent::save(); parent::save();
@ -107,6 +116,9 @@ public function save() {
)); ));
} }
\wcf\system\acl\ACLHandler::getInstance()->save($roomID, $this->objectTypeID);
\wcf\system\chat\permissions\ChatPermissionHandler::clearCache();
$this->saved(); $this->saved();
// reset values // reset values
@ -120,7 +132,7 @@ public function save() {
} }
/** /**
* @see wcf\page\IPage::assignVariables() * @see \wcf\page\IPage::assignVariables()
*/ */
public function assignVariables() { public function assignVariables() {
parent::assignVariables(); parent::assignVariables();
@ -130,7 +142,8 @@ public function assignVariables() {
WCF::getTPL()->assign(array( WCF::getTPL()->assign(array(
'action' => 'add', 'action' => 'add',
'title' => $this->title, 'title' => $this->title,
'topic' => $this->topic 'topic' => $this->topic,
'objectTypeID' => $this->objectTypeID
)); ));
} }
} }

View File

@ -15,17 +15,17 @@
*/ */
class ChatRoomEditForm extends ChatRoomAddForm { class ChatRoomEditForm extends ChatRoomAddForm {
/** /**
* @see \wcf\page\AbstractPage::$templateName * @see \wcf\page\AbstractPage::$templateName
*/ */
public $templateName = 'chatRoomAdd'; public $templateName = 'chatRoomAdd';
/** /**
* @see \wcf\acp\form\ACPForm::$activeMenuItem * @see \wcf\acp\form\ACPForm::$activeMenuItem
*/ */
public $activeMenuItem = 'wcf.acp.menu.link.chat.room.list'; 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'); public $neededPermissions = array('admin.content.chat.canEditRoom');
@ -44,7 +44,7 @@ class ChatRoomEditForm extends ChatRoomAddForm {
public $roomObj = null; public $roomObj = null;
/** /**
* @see wcf\page\IPage::readParameters() * @see \wcf\page\IPage::readParameters()
*/ */
public function readParameters() { public function readParameters() {
parent::readParameters(); parent::readParameters();
@ -57,7 +57,7 @@ public function readParameters() {
} }
/** /**
* @see wcf\form\IForm::save() * @see \wcf\form\IForm::save()
*/ */
public function save() { public function save() {
ACPForm::save(); ACPForm::save();
@ -80,6 +80,8 @@ public function save() {
I18nHandler::getInstance()->save('topic', $this->topic, 'wcf.chat.room', PackageDependencyHandler::getPackageID('timwolla.wcf.chat')); 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 // update room
$this->objectAction = new \wcf\data\chat\room\ChatRoomAction(array($this->roomID), 'update', array('data' => array( $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() { public function readData() {
parent::readData(); parent::readData();
@ -112,7 +114,7 @@ public function readData() {
} }
/** /**
* @see wcf\page\IPage::assignVariables() * @see \wcf\page\IPage::assignVariables()
*/ */
public function assignVariables() { public function assignVariables() {
parent::assignVariables(); parent::assignVariables();

View File

@ -12,7 +12,7 @@
*/ */
class ChatRoomListPage extends \wcf\page\MultipleLinkPage { class ChatRoomListPage extends \wcf\page\MultipleLinkPage {
/** /**
* @see wcf\page\AbstractPage::$neededPermissions * @see \wcf\page\AbstractPage::$neededPermissions
*/ */
public $neededPermissions = array( public $neededPermissions = array(
'admin.content.chat.canEditRoom', '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'; public $objectListClassName = '\wcf\data\chat\room\ChatRoomList';
/** /**
* @see wcf\page\MultipleLinkPage::$sortField * @see \wcf\page\MultipleLinkPage::$sortField
*/ */
public $sortField = 'position'; public $sortField = 'position';
/** /**
* @see wcf\page\MultipleLinkPage::$sortOrder * @see \wcf\page\MultipleLinkPage::$sortOrder
*/ */
public $sortOrder = 'ASC'; public $sortOrder = 'ASC';
/** /**
* @see wcf\page\IPage::show() * @see \wcf\page\IPage::show()
*/ */
public function show() { public function show() {
// set active menu item. // set active menu item.

View File

@ -13,13 +13,16 @@
* @subpackage action * @subpackage action
*/ */
class ChatLeaveAction extends AbstractAction { class ChatLeaveAction extends AbstractAction {
/**
* @see \wcf\action\AbstractAction::$neededModules
*/
public $neededModules = array('CHAT_ACTIVE'); public $neededModules = array('CHAT_ACTIVE');
//public $neededPermissions = array('user.chat.canEnter'); //public $neededPermissions = array('user.chat.canEnter');
public $room = null; public $room = null;
public $userData = array(); public $userData = array();
/** /**
* @see wcf\action\IAction::execute() * @see \wcf\action\IAction::execute()
*/ */
public function execute() { public function execute() {
parent::execute(); parent::execute();

View File

@ -13,12 +13,12 @@
*/ */
class ChatMessage extends \wcf\data\DatabaseObject { class ChatMessage extends \wcf\data\DatabaseObject {
/** /**
* @see wcf\data\DatabaseObject::$databaseTableName * @see \wcf\data\DatabaseObject::$databaseTableName
*/ */
protected static $databaseTableName = 'chat_message'; protected static $databaseTableName = 'chat_message';
/** /**
* @see wcf\data\DatabaseObject::$databaseTableIndexName * @see \wcf\data\DatabaseObject::$databaseTableIndexName
*/ */
protected static $databaseTableIndexName = 'messageID'; protected static $databaseTableIndexName = 'messageID';

View File

@ -12,7 +12,7 @@
*/ */
class ChatMessageAction extends \wcf\data\AbstractDatabaseObjectAction { class ChatMessageAction extends \wcf\data\AbstractDatabaseObjectAction {
/** /**
* @see wcf\data\AbstractDatabaseObjectAction::$className * @see \wcf\data\AbstractDatabaseObjectAction::$className
*/ */
protected $className = '\wcf\data\chat\message\ChatMessageEditor'; protected $className = '\wcf\data\chat\message\ChatMessageEditor';
} }

View File

@ -12,7 +12,7 @@
*/ */
class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor { class ChatMessageEditor extends \wcf\data\DatabaseObjectEditor {
/** /**
* @see wcf\data\DatabaseObjectDecorator::$baseClass * @see \wcf\data\DatabaseObjectDecorator::$baseClass
*/ */
protected static $baseClass = '\wcf\data\chat\message\ChatMessage'; protected static $baseClass = '\wcf\data\chat\message\ChatMessage';

View File

@ -12,7 +12,7 @@
*/ */
class ChatMessageList extends \wcf\data\DatabaseObjectList { class ChatMessageList extends \wcf\data\DatabaseObjectList {
/** /**
* @see wcf\data\DatabaseObjectList::$className * @see \wcf\data\DatabaseObjectList::$className
*/ */
public $className = 'wcf\data\chat\message\ChatMessage'; public $className = 'wcf\data\chat\message\ChatMessage';

View File

@ -13,12 +13,12 @@
*/ */
class ChatRoom extends \wcf\data\DatabaseObject implements \wcf\system\request\IRouteController { 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'; protected static $databaseTableName = 'chat_room';
/** /**
* @see wcf\data\DatabaseObject::$databaseTableIndexName * @see \wcf\data\DatabaseObject::$databaseTableIndexName
*/ */
protected static $databaseTableIndexName = 'roomID'; protected static $databaseTableIndexName = 'roomID';
@ -76,6 +76,6 @@ public function getID() {
* @return boolean * @return boolean
*/ */
public function canEnter() { public function canEnter() {
return \wcf\system\chat\permissions\ChatPermissionHandler::getInstance()->getPermission($this, 'canEnter'); return \wcf\system\chat\permission\ChatPermissionHandler::getInstance()->getPermission($this, 'canEnter');
} }
} }

View File

@ -12,17 +12,17 @@
*/ */
class ChatRoomAction extends \wcf\data\AbstractDatabaseObjectAction { class ChatRoomAction extends \wcf\data\AbstractDatabaseObjectAction {
/** /**
* @see wcf\data\AbstractDatabaseObjectAction::$className * @see \wcf\data\AbstractDatabaseObjectAction::$className
*/ */
protected $className = '\wcf\data\chat\room\ChatRoomEditor'; protected $className = '\wcf\data\chat\room\ChatRoomEditor';
/** /**
* @see wcf\data\AbstractDatabaseObjectAction::$permissionsDelete * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/ */
protected $permissionsDelete = array('admin.content.chat.canDeleteRoom'); protected $permissionsDelete = array('admin.content.chat.canDeleteRoom');
/** /**
* @see wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate * @see \wcf\data\AbstractDatabaseObjectAction::$permissionsUpdate
*/ */
protected $permissionsUpdate = array('admin.content.chat.canEditRoom'); protected $permissionsUpdate = array('admin.content.chat.canEditRoom');
} }

View File

@ -13,7 +13,7 @@
*/ */
class ChatRoomEditor extends \wcf\data\DatabaseObjectEditor implements \wcf\data\IEditableCachedObject { 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'; 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()) { public static function deleteAll(array $objectIDs = array()) {
parent::deleteAll($objectIDs); parent::deleteAll($objectIDs);

View File

@ -12,7 +12,7 @@
*/ */
class ChatRoomList extends \wcf\data\DatabaseObjectList { class ChatRoomList extends \wcf\data\DatabaseObjectList {
/** /**
* @see wcf\data\DatabaseObjectList::$className * @see \wcf\data\DatabaseObjectList::$className
*/ */
public $className = 'wcf\data\chat\room\ChatRoom'; public $className = 'wcf\data\chat\room\ChatRoom';
} }

View File

@ -8,7 +8,7 @@
/** /**
* Inserts a message * Inserts a message
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2012 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
@ -19,6 +19,10 @@ class ChatForm extends AbstractForm {
public $message = ''; public $message = '';
public $room = null; public $room = null;
public $userData = array(); public $userData = array();
/**
* @see \wcf\page\AbstractForm::$useTemplate
*/
public $useTemplate = false; public $useTemplate = false;
/** /**
@ -81,7 +85,7 @@ public function save() {
} }
/** /**
* @see \wcf\page\IPage::show() * @see \wcf\page\IPage::show()
*/ */
public function show() { public function show() {
header("HTTP/1.0 204 No Content"); header("HTTP/1.0 204 No Content");

View File

@ -22,7 +22,7 @@ class ChatMessagePage extends AbstractPage {
public $useTemplate = false; public $useTemplate = false;
/** /**
* @see \wcf\page\Page::readData() * @see \wcf\page\Page::readData()
*/ */
public function readData() { public function readData() {
parent::readData(); parent::readData();

View File

@ -12,7 +12,7 @@
*/ */
class ChatRoomCacheBuilder implements ICacheBuilder { class ChatRoomCacheBuilder implements ICacheBuilder {
/** /**
* @see wcf\system\cache\ICacheBuilder::getData() * @see \wcf\system\cache\ICacheBuilder::getData()
*/ */
public function getData(array $cacheResource) { public function getData(array $cacheResource) {
// get all chat rooms // get all chat rooms

View File

@ -1,5 +1,5 @@
<?php <?php
namespace wcf\system\chat\permissions; namespace wcf\system\chat\permission;
use \wcf\system\acl\ACLHandler; use \wcf\system\acl\ACLHandler;
use \wcf\system\package\PackageDependencyHandler; use \wcf\system\package\PackageDependencyHandler;
use \wcf\system\WCF; use \wcf\system\WCF;
@ -17,7 +17,7 @@ class ChatPermissionHandler extends \wcf\system\SingletonFactory {
protected $chatPermissions = array(); protected $chatPermissions = array();
/** /**
* @see wcf\system\SingletonFactory::init() * @see \wcf\system\SingletonFactory::init()
*/ */
protected function init() { protected function init() {
$packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat'); $packageID = PackageDependencyHandler::getPackageID('timwolla.wcf.chat');
@ -78,4 +78,14 @@ public function getPermission(\wcf\data\chat\room\ChatRoom $room, $permission) {
if (!isset($this->chatPermissions[$room->roomID][$permission])) return true; if (!isset($this->chatPermissions[$room->roomID][$permission])) return true;
return (boolean) $this->chatPermissions[$room->roomID][$permission]; 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);
}
} }

View File

@ -12,7 +12,7 @@
*/ */
class ChatRouteListener implements \wcf\system\event\IEventListener { 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) { public function execute($eventObj, $className, $eventName) {
$route = new \wcf\system\request\Route('chatAction'); $route = new \wcf\system\request\Route('chatAction');

View File

@ -17,7 +17,7 @@ class ChatPageMenuItemProvider extends DefaultPageMenuItemProvider {
/** /**
* Hides the button when there is no valid room * 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() { public function isVisible() {
// guests are not supported // guests are not supported
@ -43,7 +43,7 @@ public function isVisible() {
/** /**
* Modifies the link to show the Link we would be redirect to. * 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() { public function getLink() {
return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array( return \wcf\system\request\LinkHandler::getInstance()->getLink('Chat', array(

View File

@ -12,14 +12,14 @@
*/ */
class TimeIntervalOptionType extends TextOptionType { 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) { public function getData(\wcf\data\option\Option $option, $newValue) {
return \wcf\util\ChatUtil::timeModifier($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) { public function getFormElement(\wcf\data\option\Option $option, $value) {
$tmp = (int) ($value / 60); $tmp = (int) ($value / 60);