mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Can delete all the conversation messages of a user
This commit is contained in:
		@@ -811,6 +811,46 @@ class Conversations {
 | 
			
		||||
		return $list;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get all the messages of a user
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param int $userID Target user ID
 | 
			
		||||
	 * @return array The list of message as an array
 | 
			
		||||
	 */
 | 
			
		||||
	public function getAllUserMessages(int $userID) : array {
 | 
			
		||||
 | 
			
		||||
		//Define conditions
 | 
			
		||||
		$conditions = "WHERE ID_utilisateurs = ? ";
 | 
			
		||||
		$condVals = array(
 | 
			
		||||
			$userID
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		//Perform request
 | 
			
		||||
		return $this->getMessages($conditions, $condVals);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete all the messages of a user
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param int $userID The target user ID
 | 
			
		||||
	 * @return bool TRUE for a success / FALSE else
 | 
			
		||||
	 */
 | 
			
		||||
	public function deleteAllUserMessages(int $userID) : bool {
 | 
			
		||||
 | 
			
		||||
		//Get all the messages of the user
 | 
			
		||||
		$list = $this->getAllUserMessages($userID);
 | 
			
		||||
 | 
			
		||||
		//Delete each message
 | 
			
		||||
		foreach($list as $message){
 | 
			
		||||
			if(!$this->delete_message($message))
 | 
			
		||||
				return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Success
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get a list of conversation messages based on specified conditions
 | 
			
		||||
	 *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user