opensupports/server/controllers/article/delete.php

48 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 Delete a article.
*
* @apiName Delete
*
* @apiGroup article
*
* @apiDescription This path deletes a article.
*
* @apiPermission Staff level 2
*
* @apiParam {number} articleId Id of the article.
*
* @apiError {String} message
*
* @apiSuccess {Object} data
*
*/
2016-11-23 02:27:05 +01:00
class DeleteArticleController extends Controller {
const PATH = '/delete';
const METHOD = 'POST';
2016-11-23 02:27:05 +01:00
public function validations() {
return [
'permission' => 'staff_2',
'requestData' => [
'articleId' => [
'validation' => DataValidator::dataStoreId('article'),
'error' => ERRORS::INVALID_TOPIC
]
]
];
}
public function handler() {
$article = Article::getDataStore(Controller::request('articleId'));
Log::createLog('DELETE_ARTICLE', $article->title);
2016-11-23 02:27:05 +01:00
$article->delete();
Response::respondSuccess();
}
}