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
|
|
|
/**
|
2017-05-12 06:58:40 +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
|
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiGroup Article
|
2017-04-18 02:40:44 +02:00
|
|
|
*
|
|
|
|
* @apiDescription This path deletes a topic.
|
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @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';
|
2017-02-08 19:09:15 +01:00
|
|
|
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'));
|
|
|
|
|
2016-12-29 01:55:00 +01:00
|
|
|
Log::createLog('DELETE_TOPIC', $topic->name);
|
|
|
|
|
|
|
|
$topic->delete();
|
2016-11-23 02:27:05 +01:00
|
|
|
Response::respondSuccess();
|
|
|
|
}
|
|
|
|
}
|