summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-09-18 12:34:10 +0200
committerThomas Tanghus <thomas@tanghus.net>2013-09-18 12:34:10 +0200
commit6ba23912a7c969ce24a3b295c55a60ea640ca690 (patch)
treedbfd6dcf3b976ee5aeff7991240d104773530dd1
parent415a27c1aea82bad9f7da973854c28f15cadbee3 (diff)
downloadnextcloud-server-6ba23912a7c969ce24a3b295c55a60ea640ca690.tar.gz
nextcloud-server-6ba23912a7c969ce24a3b295c55a60ea640ca690.zip
Add getUserFolder/getAppFolder to Server.
-rw-r--r--lib/public/iservercontainer.php14
-rw-r--r--lib/server.php35
2 files changed, 49 insertions, 0 deletions
diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php
index ec7212b306e..89e71db8d17 100644
--- a/lib/public/iservercontainer.php
+++ b/lib/public/iservercontainer.php
@@ -63,6 +63,20 @@ interface IServerContainer {
function getRootFolder();
/**
+ * Returns a view to ownCloud's files folder
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getUserFolder();
+
+ /**
+ * Returns an app-specific view in ownClouds data directory
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getAppFolder();
+
+ /**
* Returns the current session
*
* @return \OCP\ISession
diff --git a/lib/server.php b/lib/server.php
index 0eee3e0f73a..9525fce9fd7 100644
--- a/lib/server.php
+++ b/lib/server.php
@@ -56,6 +56,17 @@ class Server extends SimpleContainer implements IServerContainer {
$view = new View();
return new Root($manager, $view, $user);
});
+ $this->registerService('CustomFolder', function($c) {
+ $dir = $c['CustomFolderPath'];
+ $root = $this->getRootFolder();
+ $folder = null;
+ if(!$root->nodeExists($dir)) {
+ $folder = $root->newFolder($dir);
+ } else {
+ $folder = $root->get($dir);
+ }
+ return $folder;
+ });
}
/**
@@ -98,6 +109,30 @@ class Server extends SimpleContainer implements IServerContainer {
}
/**
+ * Returns a view to ownCloud's files folder
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getUserFolder() {
+
+ $this->registerParameter('CustomFolderPath', '/files');
+ return $this->query('CustomFolder');
+
+ }
+
+ /**
+ * Returns an app-specific view in ownClouds data directory
+ *
+ * @return \OCP\Files\Folder
+ */
+ function getAppFolder() {
+
+ $this->registerParameter('CustomFolderPath', '/' . \OC_App::getCurrentApp());
+ return $this->query('CustomFolder');
+
+ }
+
+ /**
* Returns the current session
*
* @return \OCP\ISession