summaryrefslogtreecommitdiffstats
path: root/lib/private/files/node
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-06-16 16:02:30 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-03 11:11:58 +0200
commit3e97ca3b9637a44ffd366838164461bda65e889f (patch)
tree08a3dc169eea3e0eb516051c77d6aa31bd66748c /lib/private/files/node
parentf70791653cefc40f640e48dcad489237b750d85c (diff)
downloadnextcloud-server-3e97ca3b9637a44ffd366838164461bda65e889f.tar.gz
nextcloud-server-3e97ca3b9637a44ffd366838164461bda65e889f.zip
Add getUserFolder to IRootFolder
* untangle DI of user specific folders * allows to autodetect the dependency
Diffstat (limited to 'lib/private/files/node')
-rw-r--r--lib/private/files/node/root.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php
index 7ffb3674a8f..4df926748de 100644
--- a/lib/private/files/node/root.php
+++ b/lib/private/files/node/root.php
@@ -323,4 +323,33 @@ class Root extends Folder implements IRootFolder {
public function getName() {
return '';
}
+
+ /**
+ * Returns a view to user's files folder
+ *
+ * @param String $userId user ID
+ * @return \OCP\Files\Folder
+ */
+ public function getUserFolder($userId) {
+ \OC\Files\Filesystem::initMountPoints($userId);
+ $dir = '/' . $userId;
+ $folder = null;
+
+ if (!$this->nodeExists($dir)) {
+ $folder = $this->newFolder($dir);
+ } else {
+ $folder = $this->get($dir);
+ }
+
+ $dir = '/files';
+ if (!$folder->nodeExists($dir)) {
+ $folder = $folder->newFolder($dir);
+ \OC_Util::copySkeleton($userId, $folder);
+ } else {
+ $folder = $folder->get($dir);
+ }
+
+ return $folder;
+
+ }
}