Create new mountconfig files in json
This commit is contained in:
parent
46626915ef
commit
6da2c6c83e
|
@ -281,12 +281,19 @@ class OC_Mount_Config {
|
|||
private static function readData($isPersonal) {
|
||||
$parser = new \OC\ArrayParser();
|
||||
if ($isPersonal) {
|
||||
$file = OC_User::getHome(OCP\User::getUser()).'/mount.php';
|
||||
$phpFile = OC_User::getHome(OCP\User::getUser()).'/mount.php';
|
||||
$jsonFile = OC_User::getHome(OCP\User::getUser()).'/mount.json';
|
||||
} else {
|
||||
$file = OC::$SERVERROOT.'/config/mount.php';
|
||||
$phpFile = OC::$SERVERROOT.'/config/mount.php';
|
||||
$jsonFile = OC::$SERVERROOT.'/config/mount.json';
|
||||
}
|
||||
if (is_file($file)) {
|
||||
$mountPoints = $parser->parsePHP(file_get_contents($file));
|
||||
if (is_file($jsonFile)) {
|
||||
$mountPoints = json_decode(file_get_contents($jsonFile), true);
|
||||
if (is_array($mountPoints)) {
|
||||
return $mountPoints;
|
||||
}
|
||||
} elseif (is_file($phpFile)) {
|
||||
$mountPoints = $parser->parsePHP(file_get_contents($phpFile));
|
||||
if (is_array($mountPoints)) {
|
||||
return $mountPoints;
|
||||
}
|
||||
|
@ -301,35 +308,11 @@ class OC_Mount_Config {
|
|||
*/
|
||||
private static function writeData($isPersonal, $data) {
|
||||
if ($isPersonal) {
|
||||
$file = OC_User::getHome(OCP\User::getUser()).'/mount.php';
|
||||
$file = OC_User::getHome(OCP\User::getUser()).'/mount.json';
|
||||
} else {
|
||||
$file = OC::$SERVERROOT.'/config/mount.php';
|
||||
$file = OC::$SERVERROOT.'/config/mount.json';
|
||||
}
|
||||
$content = "<?php return array (\n";
|
||||
if (isset($data[self::MOUNT_TYPE_GROUP])) {
|
||||
$content .= "\t'group' => array (\n";
|
||||
foreach ($data[self::MOUNT_TYPE_GROUP] as $group => $mounts) {
|
||||
$content .= "\t\t'".$group."' => array (\n";
|
||||
foreach ($mounts as $mountPoint => $mount) {
|
||||
$content .= "\t\t\t'".addcslashes($mountPoint, "'")."' => ".str_replace("\n", '', var_export($mount, true)).", \n";
|
||||
|
||||
}
|
||||
$content .= "\t\t),\n";
|
||||
}
|
||||
$content .= "\t),\n";
|
||||
}
|
||||
if (isset($data[self::MOUNT_TYPE_USER])) {
|
||||
$content .= "\t'user' => array (\n";
|
||||
foreach ($data[self::MOUNT_TYPE_USER] as $user => $mounts) {
|
||||
$content .= "\t\t'".$user."' => array (\n";
|
||||
foreach ($mounts as $mountPoint => $mount) {
|
||||
$content .= "\t\t\t'".addcslashes($mountPoint, "'")."' => ".str_replace("\n", '', var_export($mount, true)).",\n";
|
||||
}
|
||||
$content .= "\t\t),\n";
|
||||
}
|
||||
$content .= "\t),\n";
|
||||
}
|
||||
$content .= ");\n?>";
|
||||
$content = json_encode($data);
|
||||
@file_put_contents($file, $content);
|
||||
}
|
||||
|
||||
|
|
|
@ -218,8 +218,12 @@ class Filesystem {
|
|||
$parser = new \OC\ArrayParser();
|
||||
|
||||
// Load system mount points
|
||||
if (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
|
||||
$mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
|
||||
if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file(\OC::$SERVERROOT . '/config/mount.json')) {
|
||||
if(is_file(\OC::$SERVERROOT . '/config/mount.json')){
|
||||
$mountConfig = json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mount.json'), true);
|
||||
}elseif(is_file(\OC::$SERVERROOT . '/config/mount.php')){
|
||||
$mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
|
||||
}
|
||||
if (isset($mountConfig['global'])) {
|
||||
foreach ($mountConfig['global'] as $mountPoint => $options) {
|
||||
self::mount($options['class'], $options['options'], $mountPoint);
|
||||
|
@ -255,8 +259,12 @@ class Filesystem {
|
|||
// Load personal mount points
|
||||
$root = \OC_User::getHome($user);
|
||||
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
|
||||
if (is_file($root . '/mount.php')) {
|
||||
$mountConfig = $parser->parsePHP(file_get_contents($root . '/mount.php'));
|
||||
if (is_file($root . '/mount.php') or is_file($root . '/mount.json')) {
|
||||
if (is_file($root . '/mount.json')){
|
||||
$mountConfig = json_decode(file_get_contents($root . '/mount.json'), true);
|
||||
} elseif (is_file($root . '/mount.php')){
|
||||
$mountConfig = $parser->parsePHP(file_get_contents($root . '/mount.php'));
|
||||
}
|
||||
if (isset($mountConfig['user'][$user])) {
|
||||
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
|
||||
self::mount($options['class'], $options['options'], $mountPoint);
|
||||
|
|
Loading…
Reference in New Issue