aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-11-22 00:44:48 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2012-11-22 00:44:48 -0500
commitb76d1afe193fae3bf94aed9a95e270b452e62eb8 (patch)
tree267213e5456513d2fb2d4c14caaa6d326be56ad7
parent77fdb16b7cb97f4e68949baf6796ef0e290b03f5 (diff)
downloadnextcloud-server-b76d1afe193fae3bf94aed9a95e270b452e62eb8.tar.gz
nextcloud-server-b76d1afe193fae3bf94aed9a95e270b452e62eb8.zip
Create public function initMountPoints() for initializing a specified user's mount points
-rw-r--r--lib/files/filesystem.php53
-rwxr-xr-xlib/util.php16
2 files changed, 37 insertions, 32 deletions
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index ed2814211f4..cee3cd883b3 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -229,35 +229,50 @@ class Filesystem {
self::$defaultInstance = new View($root);
//load custom mount config
- if (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
+ self::initMountPoints();
+
+ self::$loaded = true;
+
+ return true;
+ }
+
+ /**
+ * Initialize system and personal mount points for a user
+ *
+ * @param string $user
+ */
+ public static function initMountPoints($user = '') {
+ if ($user == '') {
+ $user = \OC_User::getUser();
+ }
+ // Load system mount points
+ if (is_file(\OC::$SERVERROOT.'/config/mount.php')) {
$mountConfig = include 'config/mount.php';
if (isset($mountConfig['global'])) {
foreach ($mountConfig['global'] as $mountPoint => $options) {
self::mount($options['class'], $options['options'], $mountPoint);
}
}
-
if (isset($mountConfig['group'])) {
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) {
- $mountPoint = self::setUserVars($mountPoint);
+ $mountPoint = self::setUserVars($user, $mountPoint);
foreach ($options as &$option) {
- $option = self::setUserVars($option);
+ $option = self::setUserVars($user, $option);
}
self::mount($options['class'], $options['options'], $mountPoint);
}
}
}
}
-
if (isset($mountConfig['user'])) {
- foreach ($mountConfig['user'] as $user => $mounts) {
- if ($user === 'all' or strtolower($user) === strtolower(\OC_User::getUser())) {
+ foreach ($mountConfig['user'] as $mountUser => $mounts) {
+ if ($user === 'all' or strtolower($mountUser) === strtolower($user)) {
foreach ($mounts as $mountPoint => $options) {
- $mountPoint = self::setUserVars($mountPoint);
+ $mountPoint = self::setUserVars($user, $mountPoint);
foreach ($options as &$option) {
- $option = self::setUserVars($option);
+ $option = self::setUserVars($user, $option);
}
self::mount($options['class'], $options['options'], $mountPoint);
}
@@ -265,10 +280,16 @@ class Filesystem {
}
}
}
-
- self::$loaded = true;
-
- return true;
+ // Load personal mount points
+ $root = OC_User::getHome($user);
+ if (is_file($root.'/mount.php')) {
+ $mountConfig = include $root.'/mount.php';
+ if (isset($mountConfig['user'][$user])) {
+ foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
+ self::mount($options['class'], $options['options'], $mountPoint);
+ }
+ }
+ }
}
/**
@@ -277,8 +298,8 @@ class Filesystem {
* @param string $input
* @return string
*/
- private static function setUserVars($input) {
- return str_replace('$user', \OC_User::getUser(), $input);
+ private static function setUserVars($user, $input) {
+ return str_replace('$user', $user, $input);
}
/**
diff --git a/lib/util.php b/lib/util.php
index c79afe19572..25fdcef1aea 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -58,8 +58,6 @@ class OC_Util {
$fileOperationProxy = new OC_FileProxy_FileOperations();
OC_FileProxy::register($quotaProxy);
OC_FileProxy::register($fileOperationProxy);
- // Load personal mount config
- self::loadUserMountPoints($user);
OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
}
@@ -71,20 +69,6 @@ class OC_Util {
self::$fsSetup=false;
}
- public static function loadUserMountPoints($user) {
- $user_dir = '/'.$user.'/files';
- $user_root = OC_User::getHome($user);
- $userdirectory = $user_root . '/files';
- if (is_file($user_root.'/mount.php')) {
- $mountConfig = include $user_root.'/mount.php';
- if (isset($mountConfig['user'][$user])) {
- foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
- \OC\Files\Filesystem::mount($options['class'], $options['options'], $mountPoint);
- }
- }
- }
- }
-
/**
* get the current installed version of ownCloud
* @return array