ComunicAPI/RestControllers/postsController.php

39 lines
783 B
PHP
Raw Normal View History

2017-12-24 15:35:50 +00:00
<?php
/**
* Restserver controller
*
* Posts controller
*
* @author Pierre HUBERT
*/
class postsController {
2017-12-24 16:45:05 +00:00
/**
* Get user posts
*
* @url POST /posts/get_user
*/
public function getUserPosts(){
//Get user ID
$userID = getPostUserID("userID");
//Check if user is allowed to access informations or not
if(!CS::get()->components->user->userAllowed(userID, $userID))
Rest_fatal_error(401, "You are not allowed to access this user posts !");
//Check if there is a startpoint for the posts
if(isset($_POST['startFrom'])){
$startFrom = toInt($_POST['startFrom']);
}
else
$startFrom = 0; //No start point
2017-12-25 08:58:30 +00:00
//Get the post of the user
2017-12-31 16:48:26 +00:00
$posts = CS::get()->components->posts->getUserPosts(userID, $userID, $startFrom);
2017-12-25 08:58:30 +00:00
return $posts;
2017-12-24 16:45:05 +00:00
}
2017-12-24 15:35:50 +00:00
}