Fix issue : friends posts appeared in latest posts even if friendship was not accepted.

This commit is contained in:
Pierre 2018-05-11 20:19:50 +02:00
parent 82c47e7b11
commit 0d0878daa9
2 changed files with 9 additions and 3 deletions

View File

@ -29,9 +29,10 @@ class friends {
*
* @param int $userID The ID of the user
* @param int $friendID The ID of a specific friend (default -1)
* @param bool $only_accepted Specify if only the accepted friends must be selected (default: FALSE)
* @return array The list of the friends of the user (Friend objects)
*/
public function getList(int $userID, int $friendID = -1) : array {
public function getList(int $userID, int $friendID = -1, bool $only_accepted = FALSE) : array {
//Prepare the request on the database
$tableName = $this->friendsTable.", utilisateurs";
@ -40,10 +41,15 @@ class friends {
//Check if the request is targeting a specific friend
if($friendID != -1){
$condition .= " AND ID_amis = ?";
$condition .= " AND ID_amis = ? ";
$condValues[] = $friendID;
}
//Check if only accepted friendship must be selected
if($only_accepted){
$condition .= " AND actif = 1 ";
}
//Complete conditions
$condition .= "ORDER BY utilisateurs.last_activity DESC";

View File

@ -177,7 +177,7 @@ class Posts {
$visibilityLevel = self::VISIBILITY_FRIENDS;
//Get the list of friends of the user
$friendsList = components()->friends->getList($userID);
$friendsList = components()->friends->getList($userID, -1, TRUE);
//Prepare the request on the database