public static function setupFS($user = '') { // configure the initial filesystem based on the configuration if (self::$fsSetup) { //setting up the filesystem twice can only lead to trouble return false; } // If we are not forced to load a specific user we load the one that is logged in if ($user == "" && OC_User::isLoggedIn()) { $user = OC_User::getUser(); } // the filesystem will finish when $user is not empty, // mark fs setup here to avoid doing the setup from loading // OC_Filesystem if ($user != '') { self::$fsSetup = true; } $CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data"); //first set up the local "root" storage if (!self::$rootMounted) { OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY), '/'); self::$rootMounted = true; } if ($user != "") { //if we aren't logged in, there is no use to set up the filesystem $user_dir = '/' . $user . '/files'; $user_root = OC_User::getHome($user); $userdirectory = $user_root . '/files'; if (!is_dir($userdirectory)) { mkdir($userdirectory, 0755, true); } //jail the user into his "home" directory OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user); OC_Filesystem::init($user_dir); $quotaProxy = new OC_FileProxy_Quota(); OC_FileProxy::register($quotaProxy); // Load personal mount config 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_Filesystem::mount($options['class'], $options['options'], $mountPoint); } } $mtime = filemtime($user_root . '/mount.php'); $previousMTime = OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0); if ($mtime > $previousMTime) { //mount config has changed, filecache needs to be updated OC_FileCache::triggerUpdate($user); OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime); } } OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir)); } }
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_Filesystem::mount($options['class'], $options['options'], $mountPoint); } } $mtime = filemtime($user_root . '/mount.php'); $previousMTime = OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0); if ($mtime > $previousMTime) { //mount config has changed, filecache needs to be updated OC_FileCache::triggerUpdate($user); OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime); } } }
public static function init($root) { if (self::$defaultInstance) { return false; } self::$defaultInstance = new OC_FilesystemView($root); //load custom mount config if (is_file(OC::$SERVERROOT . '/config/mount.php')) { $mountConfig = (include OC::$SERVERROOT . '/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)) { foreach ($mounts as $mountPoint => $options) { $mountPoint = self::setUserVars($mountPoint); foreach ($options as &$option) { $option = self::setUserVars($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 ($mounts as $mountPoint => $options) { $mountPoint = self::setUserVars($mountPoint); foreach ($options as &$option) { $option = self::setUserVars($option); } self::mount($options['class'], $options['options'], $mountPoint); } } } } $mtime = filemtime(OC::$SERVERROOT . '/config/mount.php'); $previousMTime = OC_Appconfig::getValue('files', 'mountconfigmtime', 0); if ($mtime > $previousMTime) { //mount config has changed, filecache needs to be updated OC_FileCache::triggerUpdate(); OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime); } } self::$loaded = true; }
private static function loadSystemMountPoints($user) { if (is_file(OC::$SERVERROOT . '/config/mount.php')) { $mountConfig = (include OC::$SERVERROOT . '/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($user, $group)) { foreach ($mounts as $mountPoint => $options) { $mountPoint = self::setUserVars($mountPoint, $user); foreach ($options as &$option) { $option = self::setUserVars($option, $user); } self::mount($options['class'], $options['options'], $mountPoint); } } } } if (isset($mountConfig['user'])) { foreach ($mountConfig['user'] as $mountUser => $mounts) { if ($user === 'all' or strtolower($mountUser) === strtolower($user)) { foreach ($mounts as $mountPoint => $options) { $mountPoint = self::setUserVars($mountPoint, $user); foreach ($options as &$option) { $option = self::setUserVars($option, $user); } self::mount($options['class'], $options['options'], $mountPoint); } } } } $mtime = filemtime(OC::$SERVERROOT . '/config/mount.php'); $previousMTime = OC_Appconfig::getValue('files', 'mountconfigmtime', 0); if ($mtime > $previousMTime) { //mount config has changed, filecache needs to be updated OC_FileCache::triggerUpdate(); OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime); } } }