Sfoglia il codice sorgente

make share folder configurable

tags/v8.0.0alpha1
Bjoern Schiessle 10 anni fa
parent
commit
c9903f2e68

+ 3
- 0
apps/files_sharing/appinfo/update.php Vedi File

$query->execute(array()); $query->execute(array());
} }


// set config to keep the Shared folder as the default location for new shares
\OCA\Files_Sharing\Helper::setShareFolder('/Shared');

} }
} }

+ 20
- 0
apps/files_sharing/lib/helper.php Vedi File

return ($result === 'yes') ? true : false; 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);
}

} }

+ 14
- 1
apps/files_sharing/lib/share/file.php Vedi File

* @return string * @return string
*/ */
public function generateTarget($filePath, $shareWith, $exclude = null) { 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 // for group shares we return the target right away
if ($shareWith === false) { if ($shareWith === false) {


\OC\Files\Filesystem::initMountPoints($shareWith); \OC\Files\Filesystem::initMountPoints($shareWith);
$view = new \OC\Files\View('/' . $shareWith . '/files'); $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); $excludeList = \OCP\Share::getItemsSharedWithUser('file', $shareWith, self::FORMAT_TARGET_NAMES);
if (is_array($exclude)) { if (is_array($exclude)) {
$excludeList = array_merge($excludeList, $exclude); $excludeList = array_merge($excludeList, $exclude);

+ 5
- 0
config/config.sample.php Vedi File

), ),
), ),


/**
* define default folder for shared files and folders
*/
'share_folder' => '/',

); );

Loading…
Annulla
Salva