1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00
Tims-Chat/files/lib/acp/form/RoomEditForm.class.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

159 lines
3.5 KiB
PHP
Raw Normal View History

2018-08-16 22:30:59 +00:00
<?php
2022-03-04 17:10:24 +00:00
2018-08-16 22:30:59 +00:00
/*
2022-03-04 17:10:24 +00:00
* Copyright (c) 2010-2022 Tim Düsterhus.
2018-08-16 22:30:59 +00:00
*
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
2023-02-22 16:45:50 +00:00
* Change Date: 2027-02-22
2018-08-16 22:30:59 +00:00
*
* On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2
* or later of the General Public License.
*/
namespace chat\acp\form;
2022-03-04 17:10:24 +00:00
use chat\data\room\Room;
use chat\data\room\RoomAction;
use wcf\data\package\PackageCache;
use wcf\form\AbstractForm;
use wcf\system\acl\ACLHandler;
use wcf\system\exception\IllegalLinkException;
use wcf\system\language\I18nHandler;
use wcf\system\WCF;
2018-08-16 22:30:59 +00:00
/**
* Shows the room edit form.
*/
2022-03-04 17:10:24 +00:00
class RoomEditForm extends RoomAddForm
{
/**
* @inheritDoc
*/
public $activeMenuItem = 'chat.acp.menu.link.room.list';
/**
* The requested chat room ID.
*
* @param int
*/
public $roomID = 0;
/**
* The requested chat room.
*
* @param Room
*/
public $room;
/**
* @inheritDoc
*/
public function readParameters()
{
if (isset($_REQUEST['id'])) {
$this->roomID = \intval($_REQUEST['id']);
}
$this->room = new Room($this->roomID);
if (!$this->room) {
throw new IllegalLinkException();
}
parent::readParameters();
}
/**
* @inheritDoc
*/
public function readData()
{
parent::readData();
if (empty($_POST)) {
$packageID = PackageCache::getInstance()->getPackageID('be.bastelstu.chat');
I18nHandler::getInstance()->setOptions(
'title',
$packageID,
$this->room->title,
'chat.room.room\d+.title'
);
I18nHandler::getInstance()->setOptions(
'topic',
$packageID,
$this->room->topic,
'chat.room.room\d+.topic'
);
$this->userLimit = $this->room->userLimit;
$this->topicUseHtml = $this->room->topicUseHtml;
}
}
/**
* @inheritDoc
*/
public function save()
{
AbstractForm::save();
$fields = [
'title' => $this->title,
'topic' => $this->topic,
'topicUseHtml' => (int)$this->topicUseHtml,
'userLimit' => $this->userLimit,
'position' => 0, // TODO
];
// update room
$this->objectAction = new RoomAction(
[ $this->room ],
'update',
[
'data' => \array_merge(
$this->additionalFields,
$fields
),
]
);
$returnValues = $this->objectAction->executeAction();
// save i18n values
$this->saveI18nValue(
$this->room,
[
'title',
'topic',
]
);
// save ACL
ACLHandler::getInstance()->save(
$this->room->roomID,
$this->aclObjectTypeID
);
$this->saved();
// show success message
WCF::getTPL()->assign('success', true);
}
/**
* @inheritDoc
*/
public function assignVariables()
{
parent::assignVariables();
I18nHandler::getInstance()->assignVariables(!empty($_POST));
WCF::getTPL()->assign([
'action' => 'edit',
'roomID' => $this->room->roomID,
'room' => $this->room,
]);
}
2018-08-16 22:30:59 +00:00
}