mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Can delete all the notifications related with a user
This commit is contained in:
		@@ -262,7 +262,7 @@ class AccountComponent {
 | 
			
		||||
	public function delete(int $userID) : bool {
 | 
			
		||||
 | 
			
		||||
		//Delete user comments
 | 
			
		||||
		if(!components()->comments->deleteAllUser($userID))
 | 
			
		||||
		/*if(!components()->comments->deleteAllUser($userID))
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
		//Delete user posts
 | 
			
		||||
@@ -278,12 +278,20 @@ class AccountComponent {
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
		//Delete user movies
 | 
			
		||||
		if(!components()->movies->deleteAllUser($userID))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Delete conversation messages
 | 
			
		||||
		if(!components()->conversations->deleteAllUserMessages($userID))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Remove users from all its conversations
 | 
			
		||||
		if(!components()->conversations->deleteAllUserConversations($userID))
 | 
			
		||||
			return FALSE;*/
 | 
			
		||||
 | 
			
		||||
		//Delete all the notifications related with the user
 | 
			
		||||
		if(!components()->notifications->deleteAllRelatedWithUser($userID))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
 | 
			
		||||
		//Delete all user friends, including friendship requests
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -306,6 +306,25 @@ class notificationComponent {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete all the notifications related with a user
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param int $userID The ID of the target user
 | 
			
		||||
	 * @return bool TRUE for a success / FALSE else
 | 
			
		||||
	 */
 | 
			
		||||
	public function deleteAllRelatedWithUser(int $userID) : bool {
 | 
			
		||||
 | 
			
		||||
		//Delete all the notifications targeting the user
 | 
			
		||||
		if(!$this->delete_all_user($userID))
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		
 | 
			
		||||
		//Delete all the notifications created by the user
 | 
			
		||||
		$notif = new Notification();
 | 
			
		||||
		$notif->set_from_user_id($userID);
 | 
			
		||||
		return $this->delete($notif);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Convert a notification object into database array
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user