2012-02-05 17:29:16 +00:00
|
|
|
<?php
|
2013-01-27 19:10:06 +00:00
|
|
|
namespace chat\acp\form;
|
2012-03-05 15:49:45 +00:00
|
|
|
use \wcf\system\language\I18nHandler;
|
|
|
|
use \wcf\system\WCF;
|
2012-02-05 17:29:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the chatroom edit form.
|
|
|
|
*
|
|
|
|
* @author Tim Düsterhus
|
2013-01-19 19:36:40 +00:00
|
|
|
* @copyright 2010-2013 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
|
|
|
/**
|
2012-02-26 16:55:44 +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
|
|
|
|
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @see \wcf\acp\form\ACPForm::$activeMenuItem
|
2012-02-05 17:29:16 +00:00
|
|
|
*/
|
2013-01-27 19:10:06 +00:00
|
|
|
public $activeMenuItem = 'chat.acp.menu.link.room.list';
|
2012-02-05 17:29:16 +00:00
|
|
|
|
|
|
|
/**
|
2012-02-26 16:55:44 +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;
|
|
|
|
|
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-26 16:55:44 +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')) {
|
2013-01-09 16:35:30 +00:00
|
|
|
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')) {
|
2013-01-09 16:35:30 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-02-26 16:55:44 +00:00
|
|
|
\wcf\system\acl\ACLHandler::getInstance()->save($this->roomID, $this->objectTypeID);
|
2013-09-08 12:45:40 +00:00
|
|
|
\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
|
2013-01-19 19:36:40 +00:00
|
|
|
$this->objectAction = new \chat\data\room\RoomAction(array($this->roomID), 'update', array('data' => array(
|
2012-02-05 17:29:16 +00:00
|
|
|
'title' => $this->title,
|
|
|
|
'topic' => $this->topic
|
|
|
|
)));
|
2012-02-11 16:42:56 +00:00
|
|
|
$this->objectAction->executeAction();
|
2012-02-05 17:29:16 +00:00
|
|
|
|
|
|
|
$this->saved();
|
|
|
|
|
|
|
|
// show success
|
|
|
|
WCF::getTPL()->assign(array(
|
|
|
|
'success' => true
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-26 16:55:44 +00:00
|
|
|
* @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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2012-02-26 16:55:44 +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
|
|
|
}
|