From 66bfb5029b3abd72fc2d2ab56dfd21840e91a2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 15 Apr 2012 17:11:08 +0200 Subject: [PATCH] Adding some pieces of Temproom-Command. --- .../chat/command/commands/Temproom.class.php | 86 +++++++++++++++++++ userGroupOption.xml | 6 ++ 2 files changed, 92 insertions(+) create mode 100644 file/lib/system/chat/command/commands/Temproom.class.php diff --git a/file/lib/system/chat/command/commands/Temproom.class.php b/file/lib/system/chat/command/commands/Temproom.class.php new file mode 100644 index 0000000..d4db662 --- /dev/null +++ b/file/lib/system/chat/command/commands/Temproom.class.php @@ -0,0 +1,86 @@ + + * @package timwolla.wcf.chat + * @subpackage system.chat.command.commands + */ +class Temproom extends \wcf\system\chat\command\AbstractRestrictedCommand { + public $enableSmilies = \wcf\system\chat\command\ICommand::SMILEY_OFF; + public $roomName = ''; + + public function __construct(\wcf\system\chat\command\CommandHandler $commandHandler) { + parent::__construct($commandHandler); + + // create room + $this->objectAction = new \wcf\data\chat\room\ChatRoomAction(array(), 'create', array('data' => array( + 'title' => 'Temproom', + 'topic' => '', + 'permanent' => 0, + 'owner' => WCF::getUser()->userID + ))); + $this->objectAction->executeAction(); + $returnValues = $this->objectAction->getReturnValues(); + $chatRoomEditor = new \wcf\data\chat\room\ChatRoomEditor($returnValues['returnValues']); + $roomID = $returnValues['returnValues']->roomID; + $this->roomName = WCF::getLanguage()->getDynamicVariable('wcf.chat.room.titleTemp', array('$roomID' => $roomID)); + + // set accurate title + $chatRoomEditor->update(array( + 'title' => $this->roomName + )); + + // set permissions + $options = \wcf\data\acl\option\ACLOption::getOptions(\wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('be.bastelstu.wcf.chat.room'))->getObjects(); + $_POST['aclValues'] = array( + 'user' => array( + // creators may do everything + WCF::getUser()->userID => array_fill_keys(array_keys($options), 1) + ), + 'group' => array( + // anyone else may do nothing + \wcf\data\user\group\UserGroup::EVERYONE => array_fill_keys(array_keys($options), 0) + ) + ); + + \wcf\system\acl\ACLHandler::getInstance()->save($roomID, \wcf\system\acl\ACLHandler::getInstance()->getObjectTypeID('be.bastelstu.wcf.chat.room')); + $this->didInit(); + } + + /** + * @see \wcf\system\chat\command\AbstractRestrictedCommand::checkPermission() + */ + public function checkPermission() { + parent::checkPermission(); + + WCF::getSession()->checkPermissions(array('user.chat.canTempRoom')); + } + + /** + * @see \wcf\system\chat\command\ICommand::getType() + */ + public function getType() { + return \wcf\data\chat\message\ChatMessage::TYPE_INFORMATION; + } + + /** + * @see \wcf\system\chat\command\ICommand::getMessage() + */ + public function getMessage() { + return $this->roomName; + } + + /** + * @see \wcf\system\chat\command\ICommand::getReceiver() + */ + public function getReceiver() { + return \wcf\system\WCF::getUser()->userID; + } +} diff --git a/userGroupOption.xml b/userGroupOption.xml index e40be2a..6b28ff5 100644 --- a/userGroupOption.xml +++ b/userGroupOption.xml @@ -26,6 +26,12 @@ 0 0 +