mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Fix issue : friends posts appeared in latest posts even if friendship was not accepted.
This commit is contained in:
		@@ -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";
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user