mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 08:35:18 +00:00
Can get the posts of a group and returns them to the API
This commit is contained in:
@ -56,6 +56,31 @@ class PostsController {
|
||||
return $this->parsePostsList($posts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group posts
|
||||
*
|
||||
* @url POST /posts/get_group
|
||||
*/
|
||||
public function getGroupPosts(){
|
||||
|
||||
//Get group ID
|
||||
$groupID = getPostGroupIdWithAccess("groupID", GroupInfo::VIEW_ACCESS);
|
||||
|
||||
//Get the startpoint for the posts
|
||||
$startFrom = postInt("startFrom", 0);
|
||||
|
||||
//Check whether the user can see members only posts or not
|
||||
$membershipLevel = components()->groups->getMembershipLevel(userID, $groupID);
|
||||
$seeAllPosts = $membershipLevel <= GroupMember::MEMBER;
|
||||
|
||||
//Get the posts of the group
|
||||
$posts = components()->posts->getGroupPosts($groupID, $seeAllPosts, $startFrom);
|
||||
|
||||
//Return parsed list of posts
|
||||
return $this->parsePostsList($posts);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest posts for the user
|
||||
*
|
||||
|
Reference in New Issue
Block a user