diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php
index 6f82c4f94a9..51f68ffb7ff 100644
--- a/htdocs/admin/dav.php
+++ b/htdocs/admin/dav.php
@@ -159,6 +159,13 @@ $message='';
$url=''.$urlwithroot.'/dav/fileserver.php';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url);
$message.='
';
+if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
+{
+ $urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:'');
+ $url=''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'';
+ $message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV public',$url);
+ $message.='
';
+}
print $message;
// End of page
diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php
index bfdc81887ff..ee3e1deb799 100644
--- a/htdocs/dav/fileserver.php
+++ b/htdocs/dav/fileserver.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2019 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/includes/sabre/autoload.php';
$user = new User($db);
-if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']!='')
+if (isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']!='')
{
$user->fetch('',$_SERVER['PHP_AUTH_USER']);
$user->getrights();
@@ -47,14 +48,17 @@ if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']!='')
$langs->loadLangs(array("main","other"));
-if(empty($conf->dav->enabled))
+if (empty($conf->dav->enabled))
accessforbidden();
+$entity = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
+
// settings
-$publicDir = $conf->dav->dir_output.'/public';
-$privateDir = $conf->dav->dir_output.'/private';
-$tmpDir = $conf->dav->dir_temp;
+$publicDir = $conf->dav->multidir_output[$entity].'/public';
+$privateDir = $conf->dav->multidir_output[$entity].'/private';
+$ecmDir = $conf->ecm->multidir_output[$entity];
+$tmpDir = $conf->dav->multidir_temp[$entity];
//var_dump($tmpDir);exit;
// Authentication callback function
@@ -100,14 +104,14 @@ $nodes = array();
// Public dir
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
{
- $nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/public');
+ $nodes[] = new \Sabre\DAV\FS\Directory($publicDir);
}
// Private dir
-$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/private');
+$nodes[] = new \Sabre\DAV\FS\Directory($privateDir);
// ECM dir
if (! empty($conf->ecm->enabled) && ! empty($conf->global->DAV_ALLOW_ECM_DIR))
{
- $nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/ecm');
+ $nodes[] = new \Sabre\DAV\FS\Directory($ecmDir);
}