mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
fix website purge function
This commit is contained in:
@@ -662,7 +662,7 @@ class Website extends CommonObject
|
||||
*/
|
||||
public function purge(User $user)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
@@ -684,8 +684,22 @@ class Website extends CommonObject
|
||||
|
||||
if (!$error && !empty($this->ref)) {
|
||||
$pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref;
|
||||
// Delete content of website directory without deleting the website directory
|
||||
dol_delete_dir_recursive($pathofwebsite, 0, 0, 1);
|
||||
|
||||
dol_delete_dir_recursive($pathofwebsite);
|
||||
// Check symlink documents/website/mywebsite/medias to point to documents/medias and restore it if ko.
|
||||
// Recreate also dir of website if not found.
|
||||
$pathtomedias = DOL_DATA_ROOT.'/medias';
|
||||
$pathtomediasinwebsite = $pathofwebsite.'/medias';
|
||||
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
|
||||
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
|
||||
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists
|
||||
$result = symlink($pathtomedias, $pathtomediasinwebsite);
|
||||
if (!$result) {
|
||||
$this->errors[] = $langs->trans("ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias);
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
|
||||
Reference in New Issue
Block a user