FIX DAV compatibility with mutlicompany

This commit is contained in:
Regis Houssin 2019-01-17 08:13:32 +01:00
parent ab5aaa6b43
commit 3edaaca1db

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2018 Destailleur Laurent <eldy@users.sourceforge.net> /* Copyright (C) 2018 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2019 Regis Houssin <regis.houssin@inodbox.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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); $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->fetch('',$_SERVER['PHP_AUTH_USER']);
$user->getrights(); $user->getrights();
@ -47,14 +48,17 @@ if(isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']!='')
$langs->loadLangs(array("main","other")); $langs->loadLangs(array("main","other"));
if(empty($conf->dav->enabled)) if (empty($conf->dav->enabled))
accessforbidden(); accessforbidden();
$entity = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1));
// settings // settings
$publicDir = $conf->dav->dir_output.'/public'; $publicDir = $conf->dav->multidir_output[$entity].'/public';
$privateDir = $conf->dav->dir_output.'/private'; $privateDir = $conf->dav->multidir_output[$entity].'/private';
$tmpDir = $conf->dav->dir_temp; $ecmDir = $conf->ecm->multidir_output[$entity];
$tmpDir = $conf->dav->multidir_temp[$entity];
//var_dump($tmpDir);exit; //var_dump($tmpDir);exit;
// Authentication callback function // Authentication callback function
@ -100,14 +104,14 @@ $nodes = array();
// Public dir // Public dir
if (!empty($conf->global->DAV_ALLOW_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 // Private dir
$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/private'); $nodes[] = new \Sabre\DAV\FS\Directory($privateDir);
// ECM dir // ECM dir
if (! empty($conf->ecm->enabled) && ! empty($conf->global->DAV_ALLOW_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);
} }