Merge pull request #10352 from hregis/develop_mc

FIX DAV compatibility with mutlicompany
This commit is contained in:
Laurent Destailleur 2019-01-17 18:58:32 +01:00 committed by GitHub
commit 3187636c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 8 deletions

View File

@ -159,6 +159,13 @@ $message='';
$url='<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>'; $url='<a href="'.$urlwithroot.'/dav/fileserver.php" target="_blank">'.$urlwithroot.'/dav/fileserver.php</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url); $message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url);
$message.='<br>'; $message.='<br>';
if (! empty($conf->global->DAV_ALLOW_PUBLIC_DIR))
{
$urlEntity = (! empty($conf->multicompany->enabled)?'?entity='.$conf->entity:'');
$url='<a href="'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'" target="_blank">'.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV public',$url);
$message.='<br>';
}
print $message; print $message;
// End of page // End of page

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);
} }