diff options
Diffstat (limited to 'apps/files_sharing/lib/Helper.php')
-rw-r--r-- | apps/files_sharing/lib/Helper.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index d8e58e84b7d..931301a04c4 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -29,6 +29,7 @@ namespace OCA\Files_Sharing; use OC\Files\Filesystem; use OC\Files\View; +use OCA\Files_Sharing\AppInfo\Application; class Helper { public static function registerHooks() { @@ -63,16 +64,29 @@ class Helper { /** * get default share folder * - * @param \OC\Files\View $view + * @param \OC\Files\View|null $view + * @param string|null $userId * @return string */ - public static function getShareFolder($view = null) { + public static function getShareFolder(View $view = null, string $userId = null): string { if ($view === null) { $view = Filesystem::getView(); } - $shareFolder = \OC::$server->getConfig()->getSystemValue('share_folder', '/'); + + $config = \OC::$server->getConfig(); + $systemDefault = $config->getSystemValue('share_folder', '/'); + $allowCustomShareFolder = $config->getSystemValueBool('sharing.allow_custom_share_folder', true); + + // Init custom shareFolder + $shareFolder = $systemDefault; + if ($userId !== null && $allowCustomShareFolder) { + $shareFolder = $config->getUserValue($userId, Application::APP_ID, 'share_folder', $systemDefault); + } + + // Verify and sanitize path $shareFolder = Filesystem::normalizePath($shareFolder); + // Init path if folder doesn't exists if (!$view->file_exists($shareFolder)) { $dir = ''; $subdirs = explode('/', $shareFolder); |