make share folder configurable
This commit is contained in:
parent
a4b416f115
commit
c9903f2e68
|
@ -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');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -339,4 +339,9 @@ $CONFIG = array(
|
|||
),
|
||||
),
|
||||
|
||||
/**
|
||||
* define default folder for shared files and folders
|
||||
*/
|
||||
'share_folder' => '/',
|
||||
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue