mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-28 00:04:31 +02:00
Delete edit-topic.php
This commit is contained in:
parent
50818d162d
commit
80934ff3f8
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
use Respect\Validation\Validator as DataValidator;
|
|
||||||
DataValidator::with('CustomValidations', true);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @api {post} /article/edit-topic Edit topic
|
|
||||||
* @apiVersion 4.3.0
|
|
||||||
*
|
|
||||||
* @apiName Edit topic
|
|
||||||
*
|
|
||||||
* @apiGroup Article
|
|
||||||
*
|
|
||||||
* @apiDescription This path edits a topic.
|
|
||||||
*
|
|
||||||
* @apiPermission staff2
|
|
||||||
*
|
|
||||||
* @apiParam {Number} topicId Id of the topic.
|
|
||||||
* @apiParam {String} name The new name of the topic. Optional.
|
|
||||||
* @apiParam {String} icon The new icon of the topic. Optional.
|
|
||||||
* @apiParam {String} iconColor The new Icon's color of the topic. Optional.
|
|
||||||
* @apiParam {Boolean} private Indicates if the topic is not shown to users.
|
|
||||||
*
|
|
||||||
* @apiUse NO_PERMISSION
|
|
||||||
* @apiUse INVALID_TOPIC
|
|
||||||
*
|
|
||||||
* @apiSuccess {Object} data Empty object
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class EditTopicController extends Controller {
|
|
||||||
const PATH = '/edit-topic';
|
|
||||||
const METHOD = 'POST';
|
|
||||||
|
|
||||||
public function validations() {
|
|
||||||
return [
|
|
||||||
'permission' => 'staff_2',
|
|
||||||
'requestData' => [
|
|
||||||
'topicId' => [
|
|
||||||
'validation' => DataValidator::dataStoreId('topic'),
|
|
||||||
'error' => ERRORS::INVALID_TOPIC
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handler() {
|
|
||||||
$topic = Topic::getDataStore(Controller::request('topicId'));
|
|
||||||
|
|
||||||
if(Controller::request('name')) {
|
|
||||||
$topic->name = Controller::request('name');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Controller::request('iconColor')) {
|
|
||||||
$topic->iconColor = Controller::request('iconColor');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Controller::request('icon')) {
|
|
||||||
$topic->icon = Controller::request('icon');
|
|
||||||
}
|
|
||||||
if (Controller::request('private') !== null) {
|
|
||||||
$topic->private = Controller::request('private');
|
|
||||||
}
|
|
||||||
|
|
||||||
$topic->store();
|
|
||||||
Response::respondSuccess();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user