opensupports/server/controllers/article/delete-topic.php

50 lines
1.1 KiB
PHP
Raw Normal View History

2016-11-23 02:27:05 +01:00
<?php
use Respect\Validation\Validator as DataValidator;
DataValidator::with('CustomValidations', true);
2017-04-18 02:40:44 +02:00
/**
* @api {post} /article/delete-topic Delete topic
2019-03-06 16:47:24 +01:00
* @apiVersion 4.4.0
2017-04-18 02:40:44 +02:00
*
* @apiName Delete topic
*
* @apiGroup Article
2017-04-18 02:40:44 +02:00
*
* @apiDescription This path deletes a topic.
*
* @apiPermission staff2
2017-04-18 02:40:44 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiParam {Number} topicId Id of the topic.
2017-04-18 02:40:44 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiUse NO_PERMISSION
* @apiUse INVALID_TOPIC
2017-04-18 02:40:44 +02:00
*
2017-04-21 08:09:24 +02:00
* @apiSuccess {Object} data Empty object
2017-04-18 02:40:44 +02:00
*
*/
2016-11-23 02:27:05 +01:00
class DeleteTopicController extends Controller {
const PATH = '/delete-topic';
const METHOD = 'POST';
2016-11-23 02:27:05 +01:00
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'));
Log::createLog('DELETE_TOPIC', $topic->name);
$topic->delete();
2016-11-23 02:27:05 +01:00
Response::respondSuccess();
}
}