aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-08-13 12:55:14 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-08-19 10:21:16 +0200
commit1519f018a4a4104b978896a893845c2166742a45 (patch)
tree9a7a27fdac2a676b81797307b1491f1710c2709f
parent2b449dd4fd66ca0b7d07fcd3b835b7af55f1d384 (diff)
downloadnextcloud-server-1519f018a4a4104b978896a893845c2166742a45.tar.gz
nextcloud-server-1519f018a4a4104b978896a893845c2166742a45.zip
make share folder configurable
-rw-r--r--apps/files_sharing/appinfo/update.php3
-rw-r--r--apps/files_sharing/lib/helper.php20
-rw-r--r--apps/files_sharing/lib/share/file.php15
-rwxr-xr-xconfig/config.sample.php5
4 files changed, 42 insertions, 1 deletions
diff --git a/apps/files_sharing/appinfo/update.php b/apps/files_sharing/appinfo/update.php
index 72acdbac736..e393b1575af 100644
--- a/apps/files_sharing/appinfo/update.php
+++ b/apps/files_sharing/appinfo/update.php
@@ -113,5 +113,8 @@ function removeSharedFolder($mkdirs = true, $chunkSize = 99) {
$query->execute(array());
}
+ // set config to keep the Shared folder as the default location for new shares
+ \OCA\Files_Sharing\Helper::setShareFolder('/Shared');
+
}
}
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index c15b1d48114..f444404c2b1 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -237,4 +237,24 @@ class Helper {
return ($result === 'yes') ? true : false;
}
+ /**
+ * get default share folder
+ *
+ * @return string
+ */
+ public static function getShareFolder() {
+ $shareFolder = \OCP\Config::getSystemValue('share_folder', '/');
+
+ return \OC\Files\Filesystem::normalizePath($shareFolder);
+ }
+
+ /**
+ * set default share folder
+ *
+ * @param string $shareFolder
+ */
+ public static function setShareFolder($shareFolder) {
+ \OCP\Config::setSystemValue('share_folder', $shareFolder);
+ }
+
}
diff --git a/apps/files_sharing/lib/share/file.php b/apps/files_sharing/lib/share/file.php
index 91595461a61..2ae7fdc16ab 100644
--- a/apps/files_sharing/lib/share/file.php
+++ b/apps/files_sharing/lib/share/file.php
@@ -61,7 +61,8 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
* @return string
*/
public function generateTarget($filePath, $shareWith, $exclude = null) {
- $target = '/'.basename($filePath);
+ $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
+ $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($filePath));
// for group shares we return the target right away
if ($shareWith === false) {
@@ -70,6 +71,18 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
\OC\Files\Filesystem::initMountPoints($shareWith);
$view = new \OC\Files\View('/' . $shareWith . '/files');
+
+ if (!$view->is_dir($shareFolder)) {
+ $dir = '';
+ $subdirs = explode('/', $shareFolder);
+ foreach ($subdirs as $subdir) {
+ $dir = $dir . '/' . $subdir;
+ if (!$view->is_dir($dir)) {
+ $view->mkdir($dir);
+ }
+ }
+ }
+
$excludeList = \OCP\Share::getItemsSharedWithUser('file', $shareWith, self::FORMAT_TARGET_NAMES);
if (is_array($exclude)) {
$excludeList = array_merge($excludeList, $exclude);
diff --git a/config/config.sample.php b/config/config.sample.php
index a0f3e0a4e72..2aa240afe22 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -341,4 +341,9 @@ $CONFIG = array(
),
),
+/**
+ * define default folder for shared files and folders
+ */
+'share_folder' => '/',
+
);