forked from Wavyzz/dolibarr
Fix dol_include_once could not work to get external url of a module
This commit is contained in:
@@ -333,7 +333,7 @@ function dol_include_once($relpath, $classname='')
|
||||
* Return path of url or filesystem. Return alternate root if exists
|
||||
*
|
||||
* @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
|
||||
* @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path)
|
||||
* @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
|
||||
* @return string Full filesystem path (if mode=0), Full url path (if mode=1)
|
||||
*/
|
||||
function dol_buildpath($path, $type=0)
|
||||
@@ -364,6 +364,8 @@ function dol_buildpath($path, $type=0)
|
||||
$res='';
|
||||
if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value
|
||||
if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value
|
||||
if ($type == 3) $res = DOL_URL_ROOT.'/'.$path;
|
||||
|
||||
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
|
||||
{
|
||||
if ($key == 'main') continue;
|
||||
@@ -379,7 +381,18 @@ function dol_buildpath($path, $type=0)
|
||||
}
|
||||
if ($type == 2)
|
||||
{
|
||||
$res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
|
||||
$res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
|
||||
}
|
||||
if ($type == 3)
|
||||
{
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
$res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user