From 0156ef816650ec73d033ebba2107cf237d6301e3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 7 May 2014 13:19:41 +0200 Subject: [PATCH] Add coments to database and dont use sql keywords as table names --- apps/files_sharing/appinfo/database.xml | 12 ++++++++++-- apps/files_sharing/lib/external/manager.php | 7 ++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/files_sharing/appinfo/database.xml b/apps/files_sharing/appinfo/database.xml index b9c0d881fc..e55688240b 100644 --- a/apps/files_sharing/appinfo/database.xml +++ b/apps/files_sharing/appinfo/database.xml @@ -19,49 +19,57 @@ remote text true - 128 + 512 + Url of the remove owncloud instance - token + share_token text true 64 + Public share token password text true 64 + Optional password for the public share name text true 64 + Original name on the remote server owner text true 64 + User that owns the public share on the remote server user text true 64 + Local user which added the external share mountpoint text true 512 + Full path where the share is mounted mountpoint_hash text true 32 + md5 hash of the mountpoint sh_external_user diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php index d82cb83a6e..fa0005389a 100644 --- a/apps/files_sharing/lib/external/manager.php +++ b/apps/files_sharing/lib/external/manager.php @@ -50,7 +50,7 @@ class Manager { 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`, + $query = $this->connection->prepare('INSERT INTO *PREFIX*share_external(`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`) VALUES(?, ?, ?, ?, ?, ?, ?, ?)'); $mountPoint = '/' . $user->getUID() . '/files/' . $name; $hash = md5($mountPoint); @@ -71,12 +71,13 @@ class Manager { public function setup() { $user = $this->userSession->getUser(); if ($user) { - $query = $this->connection->prepare('SELECT `remote`, `token`, `password`, `mountpoint`, `owner` + $query = $this->connection->prepare('SELECT `remote`, `share_token`, `password`, `mountpoint`, `owner` FROM *PREFIX*share_external WHERE `user` = ?'); $query->execute(array($user->getUID())); while ($row = $query->fetch()) { $row['manager'] = $this; + $row['token'] = $row['share_token']; $mount = new Mount(self::STORAGE, $row['mountpoint'], $row, $this->storageLoader); $this->mountManager->addMount($mount); } @@ -109,7 +110,7 @@ class Manager { $this->mountManager->removeMount($source . '/'); } - public function remoteShare($mountPoint) { + public function removeShare($mountPoint) { $hash = md5($mountPoint); $query = $this->connection->prepare('DELETE FROM *PREFIX*share_external WHERE `mountpoint_hash` = ?'); $query->execute(array($hash));