1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-11-01 14:20:07 +00:00
Tims-Chat/file/lib/acp/form/RoomEditForm.class.php

135 lines
3.6 KiB
PHP
Raw Normal View History

2012-02-05 17:29:16 +00:00
<?php
2013-01-27 19:10:06 +00:00
namespace chat\acp\form;
use \wcf\system\language\I18nHandler;
use \wcf\system\WCF;
2012-02-05 17:29:16 +00:00
/**
* Shows the chatroom edit form.
2014-02-28 16:06:50 +00:00
*
2012-02-05 17:29:16 +00:00
* @author Tim Düsterhus
2014-02-27 22:05:09 +00:00
* @copyright 2010-2014 Tim Düsterhus
2012-02-05 17:29:16 +00:00
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
2013-01-19 19:36:40 +00:00
* @package be.bastelstu.chat
2012-02-05 17:29:16 +00:00
* @subpackage acp.form
*/
2013-01-19 19:36:40 +00:00
class RoomEditForm extends RoomAddForm {
2012-02-05 17:29:16 +00:00
/**
* @see \wcf\page\AbstractPage::$templateName
2012-02-05 17:29:16 +00:00
*/
2013-01-19 19:36:40 +00:00
public $templateName = 'roomAdd';
2012-02-05 17:29:16 +00:00
/**
* @see \wcf\acp\form\ACPForm::$activeMenuItem
2012-02-05 17:29:16 +00:00
*/
2014-03-20 23:33:10 +00:00
public $activeMenuItem = 'chat.acp.menu.link.chat';
2012-02-05 17:29:16 +00:00
/**
* @see \wcf\page\AbstractPage::$neededPermissions
2012-02-05 17:29:16 +00:00
*/
2013-01-19 19:36:40 +00:00
public $neededPermissions = array('admin.chat.canEditRoom');
2012-02-05 17:29:16 +00:00
/**
* room id
*
* @var integer
*/
public $roomID = 0;
/**
* room object
*
2013-01-19 19:36:40 +00:00
* @var \chat\data\room\Room
2012-02-05 17:29:16 +00:00
*/
public $roomObj = null;
/**
* @see \wcf\page\IPage::readParameters()
2012-02-05 17:29:16 +00:00
*/
public function readParameters() {
parent::readParameters();
if (isset($_REQUEST['id'])) $this->roomID = intval($_REQUEST['id']);
2013-01-19 19:36:40 +00:00
$this->roomObj = new \chat\data\room\Room($this->roomID);
2012-02-05 17:29:16 +00:00
if (!$this->roomObj->roomID) {
throw new \wcf\system\exception\IllegalLinkException();
}
2013-05-31 00:07:03 +00:00
if (!$this->roomObj->permanent) {
throw new \wcf\system\exception\PermissionDeniedException();
}
2012-02-05 17:29:16 +00:00
}
/**
* @see \wcf\form\IForm::save()
2012-02-05 17:29:16 +00:00
*/
public function save() {
2013-01-19 19:36:40 +00:00
\wcf\form\AbstractForm::save();
2012-02-05 17:29:16 +00:00
2013-01-19 19:36:40 +00:00
$this->title = 'chat.room.title'.$this->roomObj->roomID;
2012-02-05 17:29:16 +00:00
if (I18nHandler::getInstance()->isPlainValue('title')) {
I18nHandler::getInstance()->remove($this->title);
2012-02-05 17:29:16 +00:00
$this->title = I18nHandler::getInstance()->getValue('title');
}
else {
2013-01-19 19:36:40 +00:00
I18nHandler::getInstance()->save('title', $this->title, 'chat.room', \chat\util\ChatUtil::getPackageID());
2012-02-05 17:29:16 +00:00
}
2013-01-19 19:36:40 +00:00
$this->topic = 'chat.room.topic'.$this->roomObj->roomID;
2012-02-05 17:29:16 +00:00
if (I18nHandler::getInstance()->isPlainValue('topic')) {
I18nHandler::getInstance()->remove($this->topic);
2012-02-05 17:29:16 +00:00
$this->topic = I18nHandler::getInstance()->getValue('topic');
}
else {
2013-01-19 19:36:40 +00:00
I18nHandler::getInstance()->save('topic', $this->topic, 'chat.room', \chat\util\ChatUtil::getPackageID());
2012-02-05 17:29:16 +00:00
}
\wcf\system\acl\ACLHandler::getInstance()->save($this->roomID, $this->objectTypeID);
\wcf\system\acl\ACLHandler::getInstance()->disableAssignVariables();
2013-01-19 19:36:40 +00:00
\chat\system\permission\PermissionHandler::clearCache();
2012-02-05 17:29:16 +00:00
// update room
$this->objectAction = new \chat\data\room\RoomAction(array($this->roomID), 'update', array('data' => array_merge($this->additionalFields, array(
2012-02-05 17:29:16 +00:00
'title' => $this->title,
'topic' => $this->topic,
'maxUsers' => $this->maxUsers
))));
$this->objectAction->executeAction();
2012-02-05 17:29:16 +00:00
$this->saved();
// show success
WCF::getTPL()->assign(array(
'success' => true
));
}
/**
* @see \wcf\page\IPage::readData()
2012-02-05 17:29:16 +00:00
*/
public function readData() {
parent::readData();
if (!count($_POST)) {
2013-01-19 19:36:40 +00:00
I18nHandler::getInstance()->setOptions('title', \chat\util\ChatUtil::getPackageID(), $this->roomObj->title, 'chat.room.title\d+');
I18nHandler::getInstance()->setOptions('topic', \chat\util\ChatUtil::getPackageID(), $this->roomObj->topic, 'chat.room.topic\d+');
2012-02-05 17:29:16 +00:00
$this->title = $this->roomObj->title;
$this->topic = $this->roomObj->topic;
$this->maxUsers = $this->roomObj->maxUsers;
2012-02-05 17:29:16 +00:00
}
}
/**
* @see \wcf\page\IPage::assignVariables()
2012-02-05 17:29:16 +00:00
*/
public function assignVariables() {
parent::assignVariables();
I18nHandler::getInstance()->assignVariables((bool) count($_POST));
WCF::getTPL()->assign(array(
'roomID' => $this->roomID,
'action' => 'edit'
));
}
2012-12-20 17:46:38 +00:00
}