mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09:29 +00:00
Can delete all the conversation messages of a user
This commit is contained in:
parent
61011c35a2
commit
478a0480b7
@ -811,6 +811,46 @@ class Conversations {
|
|||||||
return $list;
|
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
|
* Get a list of conversation messages based on specified conditions
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user