diff options
author | Björn Schießle <schiessle@owncloud.com> | 2012-10-09 15:05:49 +0200 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2012-10-09 15:18:21 +0200 |
commit | 293484d1ee6da53d9be1a82b962b3daa2a28276b (patch) | |
tree | efa75a90114cbcfb959afc11f9da08e4002e2252 /apps/files_external/lib | |
parent | b475164e95e26c23e6710e0ca5153b752014aa59 (diff) | |
download | nextcloud-server-293484d1ee6da53d9be1a82b962b3daa2a28276b.tar.gz nextcloud-server-293484d1ee6da53d9be1a82b962b3daa2a28276b.zip |
add directory while creating mount point
Diffstat (limited to 'apps/files_external/lib')
-rwxr-xr-x | apps/files_external/lib/config.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index f87a042b386..f770bfe0756 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -109,6 +109,21 @@ class OC_Mount_Config { return $personal; } + /**
+ * Add directory for mount point to the filesystem
+ * @param OC_Fileview instance $view
+ * @param string path to mount point
+ */ + private static function addMountPointDirectory($view, $path) { + $dir = ''; + foreach ( explode('/', $path) as $pathPart) { + $dir = $dir.'/'.$pathPart; + if ( !$view->file_exists($dir)) { + $view->mkdir($dir); + } + } + } + /** * Add a mount point to the filesystem @@ -127,8 +142,33 @@ class OC_Mount_Config { if ($applicable != OCP\User::getUser() || $class == 'OC_Filestorage_Local') { return false; } + $view = new OC_FilesystemView('/'.OCP\User::getUser().'/files'); + self::addMountPointDirectory($view, ltrim($mountPoint, '/')); $mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/'); } else { + $view = new OC_FilesystemView('/'); + switch ($mountType) { + case 'user': + if ($applicable == "all") { + $users = OCP\User::getUsers(); + foreach ( $users as $user ) { + $path = $user.'/files/'.ltrim($mountPoint, '/'); + self::addMountPointDirectory($view, $path); + } + } else { + $path = $applicable.'/files/'.ltrim($mountPoint, '/'); + self::addMountPointDirectory($view, $path); + } + break; + case 'group' : + $groupMembers = OC_Group::usersInGroups(array($applicable)); + foreach ( $groupMembers as $user ) { + $path = $user.'/files/'.ltrim($mountPoint, '/'); + self::addMountPointDirectory($view, $path); + } + break; + } + $mountPoint = '/$user/files/'.ltrim($mountPoint, '/'); } $mount = array($applicable => array($mountPoint => array('class' => $class, 'options' => $classOptions))); |