summaryrefslogtreecommitdiffstats
path: root/lib/filesystem.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-04-25 00:08:45 +0200
committerRobin Appelman <icewind@owncloud.com>2012-04-25 00:12:12 +0200
commit60b924c954ac880f5d17ce91f733850c5b010e0f (patch)
tree03dc9781f42e81d7abd39cecd00aa6f47017d849 /lib/filesystem.php
parentfa502e160df470ffa2ab02d6a8e9e8a0d4f6f0f4 (diff)
downloadnextcloud-server-60b924c954ac880f5d17ce91f733850c5b010e0f.tar.gz
nextcloud-server-60b924c954ac880f5d17ce91f733850c5b010e0f.zip
initial mount configuration work
Diffstat (limited to 'lib/filesystem.php')
-rw-r--r--lib/filesystem.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/filesystem.php b/lib/filesystem.php
index dc678fba74c..1b91eabc7c1 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -196,10 +196,58 @@ class OC_Filesystem{
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);
+ }
+ }
+ }
+ }
+ }
+
self::$loaded=true;
}
/**
+ * fill in the correct values for $user, and $password placeholders
+ * @param string intput
+ * @return string
+ */
+ private static function setUserVars($input){
+ return str_replace('$user',OC_User::getUser(),$input);
+ }
+
+ /**
* get the default filesystem view
* @return OC_FilesystemView
*/