mirror of
https://github.com/Yetangitu/owncloud-apps.git
synced 2025-10-02 14:49:17 +02:00
Merge pull request #19 from ayamshanov/root_as_rootDirectory
Fixed: Root of user's Cloud can be as root directory for OPDS
This commit is contained in:
commit
ab7d0d70d7
2 changed files with 25 additions and 17 deletions
|
@ -23,27 +23,27 @@ $fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : '';
|
||||||
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
|
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
|
||||||
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName());
|
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName());
|
||||||
|
|
||||||
if (!is_null($rootPath)){
|
if (!strlen($rootPath) ||
|
||||||
if (\OC\Files\Filesystem::file_exists($rootPath) === false ){
|
\OC\Files\Filesystem::isValidPath($rootPath) === false ||
|
||||||
\OCP\JSON::error(
|
\OC\Files\Filesystem::file_exists($rootPath) === false ) {
|
||||||
array(
|
\OCP\JSON::error(
|
||||||
'data' => array('message'=> $l->t('Directory does not exist!'))
|
array(
|
||||||
)
|
'data' => array('message'=> $l->t('Directory does not exist!'))
|
||||||
);
|
)
|
||||||
} else {
|
);
|
||||||
Config::set('root_path', $rootPath);
|
} else {
|
||||||
\OCP\JSON::success(
|
Config::set('root_path', $rootPath);
|
||||||
array(
|
|
||||||
'data' => array('message'=> $l->t('Settings updated successfully.'))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Config::set('enable', $opdsEnable);
|
Config::set('enable', $opdsEnable);
|
||||||
Config::set('file_types', $fileTypes);
|
Config::set('file_types', $fileTypes);
|
||||||
Config::set('skip_list', $skipList);
|
Config::set('skip_list', $skipList);
|
||||||
Config::set('feed_title', $feedTitle);
|
Config::set('feed_title', $feedTitle);
|
||||||
Config::set('id', Util::genUuid());
|
Config::set('id', Util::genUuid());
|
||||||
exit();
|
|
||||||
|
\OCP\JSON::success(
|
||||||
|
array(
|
||||||
|
'data' => array('message'=> $l->t('Settings updated successfully.'))
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -69,6 +69,14 @@ class Files extends \OCA\Files\Helper
|
||||||
* @return bool true if $child is a subdirectory of $parent
|
* @return bool true if $child is a subdirectory of $parent
|
||||||
*/
|
*/
|
||||||
public static function isChild($parent, $child) {
|
public static function isChild($parent, $child) {
|
||||||
return strpos($child, $parent . '/') === 0;
|
|
||||||
|
if ($parent[0] !== '/') {
|
||||||
|
$parent = '/' . $parent;
|
||||||
|
}
|
||||||
|
if (strlen($parent) > 1 && substr($parent, -1) !== '/') {
|
||||||
|
$parent .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (strpos($child, $parent) === 0 && strcmp($child, $parent) !== 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue