Fix pb of lang subdir in cloning website

This commit is contained in:
Laurent Destailleur
2020-05-03 14:49:06 +02:00
parent 77cf9fb569
commit da91a857a5
2 changed files with 10 additions and 6 deletions

View File

@@ -720,10 +720,11 @@ function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1)
* @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666' * @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK). Example: '0666'
* @param int $overwriteifexists Overwrite file if exists (1 by default) * @param int $overwriteifexists Overwrite file if exists (1 by default)
* @param array $arrayreplacement Array to use to replace filenames with another one during the copy (works only on file names, not on directory names). * @param array $arrayreplacement Array to use to replace filenames with another one during the copy (works only on file names, not on directory names).
* @param int $excludesubdir 0=Do not exclude subdirectories, 1=Exclude subdirectories, 2=Exclude subdirectories if name is not a 2 chars (used for country codes subdirectories).
* @return int <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK * @return int <0 if error, 0 if nothing done (all files already exists and overwriteifexists=0), >0 if OK
* @see dol_copy() * @see dol_copy()
*/ */
function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement = null) function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement = null, $excludesubdir = 0)
{ {
global $conf; global $conf;
@@ -759,8 +760,10 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep
{ {
if (is_dir($ossrcfile."/".$file)) if (is_dir($ossrcfile."/".$file))
{ {
if (empty($excludesubdir) || ($excludesubdir == 2 && strlen($file) == 2)) {
//var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists"); //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists");
$tmpresult = dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement); $tmpresult = dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement, $excludesubdir);
}
} }
else else
{ {

View File

@@ -251,8 +251,9 @@ class Website extends CommonObject
if (! $error) { if (! $error) {
$stringtodolibarrfile = "# Some properties for Dolibarr web site CMS\n"; $stringtodolibarrfile = "# Some properties for Dolibarr web site CMS\n";
$stringtodolibarrfile .= "noclone=dir_list_to_exclude_when_cloning_separated_with_comma\n"; $stringtodolibarrfile .= "param=value\n";
file_put_contents('.dolibarr', $stringtodolibarrfile); //print $conf->website->dir_output.'/'.$this->ref.'/.dolibarr';exit;
file_put_contents($conf->website->dir_output.'/'.$this->ref.'/.dolibarr', $stringtodolibarrfile);
} }
// Commit or rollback // Commit or rollback
@@ -674,7 +675,7 @@ class Website extends CommonObject
if (!$error) if (!$error)
{ {
dolCopyDir($pathofwebsiteold, $pathofwebsitenew, $conf->global->MAIN_UMASK, 0); dolCopyDir($pathofwebsiteold, $pathofwebsitenew, $conf->global->MAIN_UMASK, 0, null, 2);
// Check symlink to medias and restore it if ko // Check symlink to medias and restore it if ko
$pathtomedias = DOL_DATA_ROOT.'/medias'; // Target $pathtomedias = DOL_DATA_ROOT.'/medias'; // Target