diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index d1a24ff072c..17858b9991c 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -113,7 +113,7 @@ $tabcond[1] = (!empty($conf->website->enabled)); // List of help for fields $tabhelp = array(); -$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref')); +$tabhelp[1] = array('ref'=>$langs->trans("EnterAnyCode"), 'virtualhost'=>$langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/websiteref')); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); @@ -271,8 +271,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { if ($resql) { $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09')); if ($newname != $website->ref) { - $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref; - $destfile = DOL_DATA_ROOT.'/website/'.$newname; + $srcfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website->ref; + $destfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$newname; if (dol_is_dir($destfile)) { $error++; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index a4db07f95c0..5d553887777 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -173,7 +173,7 @@ class FormWebsite $langs->load("admin"); - $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.'/website/samples', 'files', 0, '^page-sample-.*\.html$'); + $listofsamples = dol_dir_list(DOL_DOCUMENT_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/samples', 'files', 0, '^page-sample-.*\.html$'); $arrayofsamples = array(); $arrayofsamples['empty'] = 'EmptyPage'; // Always this one first diff --git a/htdocs/core/filemanagerdol/connectors/php/config.php b/htdocs/core/filemanagerdol/connectors/php/config.php index 73c222841cc..c2d7478e36e 100644 --- a/htdocs/core/filemanagerdol/connectors/php/config.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.php @@ -50,7 +50,7 @@ $Config['Enabled'] = true; $extEntity = (empty($entity) ? 1 : $entity); // For multicompany with external access $Config['UserFilesPath'] = DOL_URL_ROOT.'/viewimage.php?modulepart=medias'.(empty($website) ? '' : '_'.$website).'&entity='.$extEntity.'&file='; -$Config['UserFilesAbsolutePathRelative'] = (empty($website) ? ((!empty($entity) ? '/'.$entity : '').'/medias/') : ('/website/'.$website)); +$Config['UserFilesAbsolutePathRelative'] = (!empty($entity) ? '/'.$entity : '').(empty($website) ? '/medias/' : ('/website/'.$website)); // Fill the following value it you prefer to specify the absolute path for the diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ca907ae6f1c..eeb68458252 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -495,7 +495,7 @@ function includeContainer($containerref) $containerref .= '.php'; } - $fullpathfile = DOL_DATA_ROOT.'/website/'.$websitekey.'/'.$containerref; + $fullpathfile = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity.'/' : '').'/website/'.$websitekey.'/'.$containerref; if (empty($includehtmlcontentopened)) { $includehtmlcontentopened = 0; @@ -984,7 +984,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so if (!$error && (empty($max) || ($found < $max)) && (preg_match('/sitefiles/', $algo))) { global $dolibarr_main_data_root; - $pathofwebsite = $dolibarr_main_data_root.'/website/'.$website->ref; + $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity.'/' : '').'/website/'.$website->ref; $filehtmlheader = $pathofwebsite.'/htmlheader.html'; $filecss = $pathofwebsite.'/styles.css.php'; $filejs = $pathofwebsite.'/javascript.js.php'; diff --git a/htdocs/public/website/index.php b/htdocs/public/website/index.php index d72fedefa7e..4b0342693d8 100644 --- a/htdocs/public/website/index.php +++ b/htdocs/public/website/index.php @@ -169,9 +169,9 @@ if ($pageid == 'css') { // No more used ? //if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); //else header('Cache-Control: no-cache'); - $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/styles.css.php'; + $original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/styles.css.php'; } else { - $original_file = $dolibarr_main_data_root.'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; + $original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey.'/page'.$pageid.'.tpl.php'; } // Find the subdirectory name as the reference diff --git a/htdocs/public/website/styles.css.php b/htdocs/public/website/styles.css.php index a0002b5380b..73cbed73dbd 100644 --- a/htdocs/public/website/styles.css.php +++ b/htdocs/public/website/styles.css.php @@ -122,7 +122,7 @@ if (empty($pageid)) // Security: Delete string ../ into $original_file global $dolibarr_main_data_root; -$original_file = $dolibarr_main_data_root.'/website/'.$website.'/styles.css.php'; +$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/styles.css.php'; // Find the subdirectory name as the reference $refname = basename(dirname($original_file)."/"); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 80a48048151..8dfaf284ea5 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -587,6 +587,8 @@ class Website extends CommonObject */ public function delete(User $user, $notrigger = false) { + global $conf; + dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; @@ -618,7 +620,7 @@ class Website extends CommonObject } if (!$error && !empty($this->ref)) { - $pathofwebsite = DOL_DATA_ROOT.'/website/'.$this->ref; + $pathofwebsite = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$this->ref; dol_delete_dir_recursive($pathofwebsite); } @@ -678,8 +680,8 @@ class Website extends CommonObject $oldidforhome = $object->fk_default_home; $oldref = $object->ref; - $pathofwebsiteold = $dolibarr_main_data_root.'/website/'.dol_sanitizeFileName($oldref); - $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.dol_sanitizeFileName($newref); + $pathofwebsiteold = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($oldref); + $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.dol_sanitizeFileName($newref); dol_delete_dir_recursive($pathofwebsitenew); $fileindex = $pathofwebsitenew.'/index.php'; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 0126f8a4dc4..6b65df983ca 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -642,7 +642,7 @@ class WebsitePage extends CommonObject if ($result > 0) { global $dolibarr_main_data_root; - $pathofwebsite = $dolibarr_main_data_root.'/website/'.$websiteobj->ref; + $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websiteobj->ref; $filealias = $pathofwebsite.'/'.$this->pageurl.'.php'; $filetpl = $pathofwebsite.'/page'.$this->id.'.tpl.php'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8ac4d612264..346a6715647 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -226,7 +226,7 @@ if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createco global $dolibarr_main_data_root; -$pathofwebsite = $dolibarr_main_data_root.'/website/'.$websitekey; +$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey; $filehtmlheader = $pathofwebsite.'/htmlheader.html'; $filecss = $pathofwebsite.'/styles.css.php'; $filejs = $pathofwebsite.'/javascript.js.php'; @@ -1924,7 +1924,7 @@ if ($usercanedit && (($action == 'updatesource' || $action == 'updatecontent' || $tmpwebsite = new Website($db); if ($newwebsiteid > 0 && $newwebsiteid != $object->id) { $tmpwebsite->fetch($newwebsiteid); - $pathofwebsitenew = $dolibarr_main_data_root.'/website/'.$tmpwebsite->ref; + $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$tmpwebsite->ref; } else { $tmpwebsite = $object; } @@ -2573,7 +2573,7 @@ if (!GETPOST('hide_websitemenu')) { if ($websitekey) { $virtualurl = ''; - $dataroot = DOL_DATA_ROOT.'/website/'.$websitekey; + $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$websitekey; if (!empty($object->virtualhost)) { $virtualurl = $object->virtualhost; } @@ -3342,7 +3342,7 @@ if ($action == 'editcss') { // VirtualHost print ''; - $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/{s1}'.$websitekey.'{s2}'); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/{s1}'.$websitekey.'{s2}'); $htmltext = str_replace(array('{s1}', '{s2}'), array('', ''), $htmltext); $htmltext .= '
'; $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); @@ -3528,7 +3528,7 @@ if ($action == 'createsite') { print ''; $htmltext = $langs->trans("SetHereVirtualHost", '{s1}'); - $htmltext = str_replace('{s1}', DOL_DATA_ROOT.'/website/websiteref', $htmltext); + $htmltext = str_replace('{s1}', DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/websiteref', $htmltext); $htmltext .= '
'; $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}');