mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09:29 +00:00
Splited access_level function in two
This commit is contained in:
parent
f4620717c2
commit
a10c89cd5d
@ -33,6 +33,14 @@ class postsController {
|
|||||||
//Get the post of the user
|
//Get the post of the user
|
||||||
$posts = CS::get()->components->posts->getUserPosts(userID, $userID, $startFrom);
|
$posts = CS::get()->components->posts->getUserPosts(userID, $userID, $startFrom);
|
||||||
|
|
||||||
|
//Process the list of posts
|
||||||
|
foreach($posts as $num => $infos){
|
||||||
|
|
||||||
|
//Get access level to the post
|
||||||
|
$access_level = CS::get()->components->posts->access_level_with_infos($infos, userID);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +187,20 @@ class Posts {
|
|||||||
//Get informations about the post
|
//Get informations about the post
|
||||||
$post_infos = $this->get_single($postID);
|
$post_infos = $this->get_single($postID);
|
||||||
|
|
||||||
|
return $this->access_level_with_infos($post_infos, $userID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the access level of a user about a post
|
||||||
|
*
|
||||||
|
* This function requires the informations about the post
|
||||||
|
*
|
||||||
|
* @param array $post_infos Informations about the post
|
||||||
|
* @param int $userID The ID of the user to check
|
||||||
|
* @return int The access level over the post
|
||||||
|
*/
|
||||||
|
public function access_level_with_infos(array $post_infos, int $userID) : int {
|
||||||
|
|
||||||
//Check if the user is the owner of the post
|
//Check if the user is the owner of the post
|
||||||
if($post_infos['userID'] == $userID)
|
if($post_infos['userID'] == $userID)
|
||||||
return $this::FULL_ACCESS;
|
return $this::FULL_ACCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user