From c058baf39467817186f401ea1b1e67132ad01476 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 31 Dec 2017 17:48:26 +0100 Subject: [PATCH] Moved visibility level detection --- RestControllers/postsController.php | 5 +---- classes/components/posts.php | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/RestControllers/postsController.php b/RestControllers/postsController.php index 58f6110..a8ccc3b 100644 --- a/RestControllers/postsController.php +++ b/RestControllers/postsController.php @@ -30,11 +30,8 @@ class postsController { else $startFrom = 0; //No start point - //Get visibility level for the post - $visibility_level = CS::get()->components->posts->getUserVisibility(userID, $userID); - //Get the post of the user - $posts = CS::get()->components->posts->getUserPosts(userID, $userID, $visibility_level, $startFrom); + $posts = CS::get()->components->posts->getUserPosts(userID, $userID, $startFrom); return $posts; } diff --git a/classes/components/posts.php b/classes/components/posts.php index ab12b1d..84f9990 100644 --- a/classes/components/posts.php +++ b/classes/components/posts.php @@ -70,17 +70,19 @@ class Posts { * * @param int $userID The ID of the user making the request * @param int $targetID The ID of the target user - * @param int $visibilityLevel Visibility level required * @param int $startPoint The startpoint for the request (0 stands for none) * @param int $limit The maximum number of messages to fetch */ - public function getUserPosts(int $userID, int $targetID, int $visibilityLevel, int $startPoint = 0, int $limit = 10) : array { + public function getUserPosts(int $userID, int $targetID, int $startPoint = 0, int $limit = 10) : array { //Check the value of limit (security) if($limit < 1){ throw new Exception("The limit of the query must absolutly be positive !"); } + //Get user visibility level + $visibilityLevel = $this->getUserVisibility($userID, $targetID); + //Prepare the request on the database $conditions = "WHERE ID_personne = ? AND ("; $dataConds = array($targetID);