From 24e24f1b6535091a862575b613bf152c9eabfde2 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Wed, 13 Jul 2011 15:27:16 -0400 Subject: [PATCH] Add support for copying files between shared folders, add check to fromTmpFile() to confirm path is writeable --- apps/files_sharing/sharedstorage.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php index a547560659a..13054d21c5f 100644 --- a/apps/files_sharing/sharedstorage.php +++ b/apps/files_sharing/sharedstorage.php @@ -355,10 +355,15 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { } public function copy($path1, $path2) { - $source = $this->getSource($path1); - if ($source) { - $storage = OC_FILESYSTEM::getStorage($source); - return $storage->copy($this->getInternalPath($source), $path2); + if ($path2 == "" || $path2 == "/") { + // TODO Construct new shared item or should this not be allowed? + } else { + if ($this->is_writeable($path)) { + $tmpFile = $this->toTmpFile($path1); + return $this->fromTmpFile($tmpFile, $path2); + } else { + return false; + } } } @@ -378,11 +383,15 @@ class OC_FILESTORAGE_SHARED extends OC_FILESTORAGE { } } - public function fromTmpFile($tmpPath, $path) { - $source = $this->getSource($tmpPath); - if ($source) { - $storage = OC_FILESYSTEM::getStorage($source); - return $storage->fromTmpFile($this->getInternalPath($source), $path); + public function fromTmpFile($tmpFile, $path) { + if ($this->is_writeable($path)) { + $source = $this->getSource($path); + if ($source) { + $storage = OC_FILESYSTEM::getStorage($source); + return $storage->fromTmpFile($tmpFile, $this->getInternalPath($source)); + } + } else { + return false; } }