Can delete all the notifications related with a user

This commit is contained in:
Pierre 2018-05-10 08:36:23 +02:00
parent 47fd14f617
commit 8f628327cf
2 changed files with 28 additions and 1 deletions

View File

@ -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

View File

@ -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
*