]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add getUserFolder/getAppFolder to Server.
authorThomas Tanghus <thomas@tanghus.net>
Wed, 18 Sep 2013 10:34:10 +0000 (12:34 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Wed, 18 Sep 2013 10:34:10 +0000 (12:34 +0200)
lib/public/iservercontainer.php
lib/server.php

index ec7212b306e2777666aec24178847e2b751a5f6b..89e71db8d171a85a00f81603c636af7368e1de29 100644 (file)
@@ -62,6 +62,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
         *
index 0eee3e0f73a808ca061aef7150dd4cb622ebe4b5..9525fce9fd73afa94baa2addabe8aee4c9c05d80 100644 (file)
@@ -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;
+               });
        }
 
        /**
@@ -97,6 +108,30 @@ class Server extends SimpleContainer implements IServerContainer {
                return $this->query('RootFolder');
        }
 
+       /**
+        * 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
         *