mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-23 22:09:29 +00:00
Background image is deleted on account deletion.
This commit is contained in:
parent
4c02f6a2a4
commit
2bf74a9ad0
@ -434,6 +434,9 @@ class AccountComponent {
|
|||||||
if(!components()->accountImage->delete($userID))
|
if(!components()->accountImage->delete($userID))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if(!components()->backgroundImage->delete($userID))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
//Delete connections to all the services
|
//Delete connections to all the services
|
||||||
if(!$this->deleteAllUserLoginTokens($userID))
|
if(!$this->deleteAllUserLoginTokens($userID))
|
||||||
return FALSE;*/
|
return FALSE;*/
|
||||||
@ -441,6 +444,8 @@ class AccountComponent {
|
|||||||
//Delete user from the database
|
//Delete user from the database
|
||||||
//WILL BE IMPLEMENTED WHEN LEGACY VERSION WILL BE REMOVED
|
//WILL BE IMPLEMENTED WHEN LEGACY VERSION WILL BE REMOVED
|
||||||
|
|
||||||
|
exit("Notice: Account deletion should be available soon...");
|
||||||
|
|
||||||
//Success
|
//Success
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,12 @@ class BackgroundImage {
|
|||||||
/**
|
/**
|
||||||
* Returns the path of a background image
|
* Returns the path of a background image
|
||||||
*
|
*
|
||||||
* @param Integer $userID The ID of the user on which we perform research
|
* @param int $userID The ID of the user on which we perform research
|
||||||
* @return String The URL pointing on the background image
|
* @return string The URL pointing on the background image
|
||||||
*/
|
*/
|
||||||
public function getPath(int $userID) : string {
|
public function getPath(int $userID) : string {
|
||||||
//First, check if the background image exists
|
//First, check if the background image exists
|
||||||
$backgroundImageRefFile = $this->files_path."adresse_imgfond/".$userID.".txt";
|
$backgroundImageRefFile = $this->getPathMetadata($userID);
|
||||||
if(file_exists($backgroundImageRefFile)){
|
if(file_exists($backgroundImageRefFile)){
|
||||||
|
|
||||||
//Get background image path and return it
|
//Get background image path and return it
|
||||||
@ -51,6 +51,48 @@ class BackgroundImage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the account image of a user (if any)
|
||||||
|
*
|
||||||
|
* @param int $userID The ID of the target user
|
||||||
|
* @return bool TRUE for a success / FALSE else
|
||||||
|
*/
|
||||||
|
public function delete(int $userID) : bool {
|
||||||
|
|
||||||
|
//Get the path to the background image
|
||||||
|
$refFile = $this->getPathMetadata($userID);
|
||||||
|
|
||||||
|
//Check if ref file exists or not
|
||||||
|
if(file_exists($refFile)){
|
||||||
|
|
||||||
|
$file_target = $this->files_path.file_get_contents($refFile);
|
||||||
|
|
||||||
|
//Delete file
|
||||||
|
if(file_exists($file_target)){
|
||||||
|
if(!unlink($file_target))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Unlink reference file
|
||||||
|
return unlink($refFile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Nothing to be done
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path to the file containing the path to the background image
|
||||||
|
*
|
||||||
|
* @param int $userID Target user ID
|
||||||
|
* @return string The path to the file
|
||||||
|
*/
|
||||||
|
private function getPathMetadata(int $userID) : string {
|
||||||
|
return $this->files_path."adresse_imgfond/".$userID.".txt";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Register class
|
//Register class
|
||||||
|
Loading…
Reference in New Issue
Block a user