]> source.dussan.org Git - nextcloud-server.git/commitdiff
add remote/add external shares to manager
authorRobin Appelman <icewind@owncloud.com>
Fri, 2 May 2014 09:27:40 +0000 (11:27 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Sat, 14 Jun 2014 08:10:37 +0000 (10:10 +0200)
apps/files_sharing/lib/external/manager.php

index ffb673723aacc75717c18c731a035d0089ab2ad4..d82cb83a6e718195c742cd2b4b7233893d189ac3 100644 (file)
@@ -47,6 +47,27 @@ class Manager {
                $this->storageLoader = $storageLoader;
        }
 
+       public function addShare($remote, $token, $password, $name, $owner) {
+               $user = $this->userSession->getUser();
+               if ($user) {
+                       $query = $this->connection->prepare('INSERT INTO *PREFIX*share_external(`remote`, `token`, `password`,
+                               `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`) VALUES(?, ?, ?, ?, ?, ?, ?, ?)');
+                       $mountPoint = '/' . $user->getUID() . '/files/' . $name;
+                       $hash = md5($mountPoint);
+                       $query->execute(array($remote, $token, $password, $name, $owner, $user->getUID(), $mountPoint, $hash));
+
+                       $options = array(
+                               'remote' => $remote,
+                               'token' => $token,
+                               'password' => $password,
+                               'mountpoint' => $mountPoint,
+                               'owner' => $owner
+                       );
+                       $mount = new Mount(self::STORAGE, $mountPoint, $options, $this->storageLoader);
+                       $this->mountManager->addMount($mount);
+               }
+       }
+
        public function setup() {
                $user = $this->userSession->getUser();
                if ($user) {
@@ -87,4 +108,10 @@ class Manager {
                $this->mountManager->addMount($mount);
                $this->mountManager->removeMount($source . '/');
        }
+
+       public function remoteShare($mountPoint) {
+               $hash = md5($mountPoint);
+               $query = $this->connection->prepare('DELETE FROM *PREFIX*share_external WHERE `mountpoint_hash` = ?');
+               $query->execute(array($hash));
+       }
 }