load system wide configured mount points before accessing shared files
This commit is contained in:
parent
00ed2e87c9
commit
2499c24b8b
|
@ -187,7 +187,8 @@ class OC_Filesystem{
|
||||||
$user = ltrim(substr($path, 0, strpos($path, '/', 1)), '/');
|
$user = ltrim(substr($path, 0, strpos($path, '/', 1)), '/');
|
||||||
// check mount points if file was shared from a different user
|
// check mount points if file was shared from a different user
|
||||||
if ($user != OC_User::getUser()) {
|
if ($user != OC_User::getUser()) {
|
||||||
OC_Util::loadMountPoints($user);
|
OC_Util::loadUserMountPoints($user);
|
||||||
|
self::loadSystemMountPoints($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mountpoint=self::getMountPoint($path);
|
$mountpoint=self::getMountPoint($path);
|
||||||
|
@ -200,13 +201,7 @@ class OC_Filesystem{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function init($root) {
|
static private function loadSystemMountPoints($user) {
|
||||||
if(self::$defaultInstance) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
self::$defaultInstance=new OC_FilesystemView($root);
|
|
||||||
|
|
||||||
//load custom mount config
|
|
||||||
if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
|
if(is_file(OC::$SERVERROOT.'/config/mount.php')) {
|
||||||
$mountConfig=include(OC::$SERVERROOT.'/config/mount.php');
|
$mountConfig=include(OC::$SERVERROOT.'/config/mount.php');
|
||||||
if(isset($mountConfig['global'])) {
|
if(isset($mountConfig['global'])) {
|
||||||
|
@ -217,11 +212,11 @@ class OC_Filesystem{
|
||||||
|
|
||||||
if(isset($mountConfig['group'])) {
|
if(isset($mountConfig['group'])) {
|
||||||
foreach($mountConfig['group'] as $group=>$mounts) {
|
foreach($mountConfig['group'] as $group=>$mounts) {
|
||||||
if(OC_Group::inGroup(OC_User::getUser(),$group)) {
|
if(OC_Group::inGroup($user,$group)) {
|
||||||
foreach($mounts as $mountPoint=>$options) {
|
foreach($mounts as $mountPoint=>$options) {
|
||||||
$mountPoint=self::setUserVars($mountPoint);
|
$mountPoint=self::($mountPoint, $user);
|
||||||
foreach($options as &$option) {
|
foreach($options as &$option) {
|
||||||
$option=self::setUserVars($option);
|
$option=self::setUserVars($option, $user);
|
||||||
}
|
}
|
||||||
self::mount($options['class'],$options['options'],$mountPoint);
|
self::mount($options['class'],$options['options'],$mountPoint);
|
||||||
}
|
}
|
||||||
|
@ -231,11 +226,11 @@ class OC_Filesystem{
|
||||||
|
|
||||||
if(isset($mountConfig['user'])) {
|
if(isset($mountConfig['user'])) {
|
||||||
foreach($mountConfig['user'] as $user=>$mounts) {
|
foreach($mountConfig['user'] as $user=>$mounts) {
|
||||||
if($user==='all' or strtolower($user)===strtolower(OC_User::getUser())) {
|
if($user==='all' or strtolower($user)===strtolower($user)) {
|
||||||
foreach($mounts as $mountPoint=>$options) {
|
foreach($mounts as $mountPoint=>$options) {
|
||||||
$mountPoint=self::setUserVars($mountPoint);
|
$mountPoint=self::setUserVars($mountPoint, $user);
|
||||||
foreach($options as &$option) {
|
foreach($options as &$option) {
|
||||||
$option=self::setUserVars($option);
|
$option=self::setUserVars($option, $user);
|
||||||
}
|
}
|
||||||
self::mount($options['class'],$options['options'],$mountPoint);
|
self::mount($options['class'],$options['options'],$mountPoint);
|
||||||
}
|
}
|
||||||
|
@ -250,6 +245,16 @@ class OC_Filesystem{
|
||||||
OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
|
OC_Appconfig::setValue('files','mountconfigmtime',$mtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function init($root) {
|
||||||
|
if(self::$defaultInstance) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
self::$defaultInstance=new OC_FilesystemView($root);
|
||||||
|
|
||||||
|
//load custom mount config
|
||||||
|
self::loadSystemMountPoints(OC_User::getUser());
|
||||||
|
|
||||||
self::$loaded=true;
|
self::$loaded=true;
|
||||||
}
|
}
|
||||||
|
@ -259,8 +264,12 @@ class OC_Filesystem{
|
||||||
* @param string intput
|
* @param string intput
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function setUserVars($input) {
|
private static function setUserVars($input, $user) {
|
||||||
return str_replace('$user',OC_User::getUser(),$input);
|
if (isset($user)) {
|
||||||
|
return str_replace('$user', $user,$input);
|
||||||
|
} else {
|
||||||
|
return str_replace('$user',OC_User::getUser(),$input);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,7 @@ class OC_Util {
|
||||||
OC_FileProxy::register($quotaProxy);
|
OC_FileProxy::register($quotaProxy);
|
||||||
OC_FileProxy::register($fileOperationProxy);
|
OC_FileProxy::register($fileOperationProxy);
|
||||||
// Load personal mount config
|
// Load personal mount config
|
||||||
self::loadMountPoints($user);
|
self::loadUserMountPoints($user);
|
||||||
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
|
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class OC_Util {
|
||||||
self::$fsSetup=false;
|
self::$fsSetup=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loadMountPoints($user) {
|
public static function loadUserMountPoints($user) {
|
||||||
$user_dir = '/'.$user.'/files';
|
$user_dir = '/'.$user.'/files';
|
||||||
$user_root = OC_User::getHome($user);
|
$user_root = OC_User::getHome($user);
|
||||||
$userdirectory = $user_root . '/files';
|
$userdirectory = $user_root . '/files';
|
||||||
|
|
Loading…
Reference in New Issue