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/get-all Get all articles
|
2018-09-20 22:19:47 +02:00
|
|
|
* @apiVersion 4.3.0
|
2017-04-18 02:40:44 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiName Get all articles
|
2017-04-18 02:40:44 +02:00
|
|
|
*
|
2017-05-12 06:58:40 +02:00
|
|
|
* @apiGroup Article
|
2017-04-18 02:40:44 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiDescription This path retrieves all the articles.
|
2017-04-18 02:40:44 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiPermission any or user
|
2017-04-18 02:40:44 +02:00
|
|
|
*
|
2017-04-21 08:09:24 +02:00
|
|
|
* @apiUse NO_PERMISSION
|
2018-11-08 18:51:04 +01:00
|
|
|
*
|
2017-04-22 03:33:17 +02:00
|
|
|
* @apiSuccess {[Topic](#api-Data_Structures-ObjectTopic)[]} data Array of topics.
|
2017-04-18 02:40:44 +02:00
|
|
|
*/
|
|
|
|
|
2016-11-23 02:27:05 +01:00
|
|
|
class GetAllArticlesController extends Controller {
|
|
|
|
const PATH = '/get-all';
|
2017-02-08 19:09:15 +01:00
|
|
|
const METHOD = 'POST';
|
2016-11-23 02:27:05 +01:00
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
2017-01-16 20:07:53 +01:00
|
|
|
'permission' => (Controller::isUserSystemEnabled()) ? 'user' : 'any',
|
2016-11-23 02:27:05 +01:00
|
|
|
'requestData' => []
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
|
|
|
$topics = Topic::getAll();
|
|
|
|
$topicsArray = [];
|
2018-11-08 18:51:04 +01:00
|
|
|
|
2016-11-23 02:27:05 +01:00
|
|
|
foreach($topics as $topic) {
|
2018-11-08 18:51:04 +01:00
|
|
|
Controller::isStaffLogged() ? $topicsArray[] = $topic->toArray() : ($topic->private*1 ? null : $topicsArray[] = $topic->toArray()) ;
|
2016-11-23 02:27:05 +01:00
|
|
|
}
|
2018-11-08 18:51:04 +01:00
|
|
|
|
2016-11-23 02:27:05 +01:00
|
|
|
Response::respondSuccess($topicsArray);
|
|
|
|
}
|
2018-11-08 18:51:04 +01:00
|
|
|
}
|