aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-02-16 01:50:40 +0100
committerRobin Appelman <icewind@owncloud.com>2013-02-16 01:50:40 +0100
commit6da2c6c83e48fc3c7f8dd0814fe815d2b772f6eb (patch)
tree43473eb0df1c01ed75ce29aac6f98b9989d8d281
parent46626915ef6888c958111b259ae6c0d3729b5198 (diff)
downloadnextcloud-server-6da2c6c83e48fc3c7f8dd0814fe815d2b772f6eb.tar.gz
nextcloud-server-6da2c6c83e48fc3c7f8dd0814fe815d2b772f6eb.zip
Create new mountconfig files in json
-rwxr-xr-xapps/files_external/lib/config.php45
-rw-r--r--lib/files/filesystem.php16
2 files changed, 26 insertions, 35 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 6ef7f37f58b..36ef48462a7 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -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';
- }
- $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";
+ $file = OC::$SERVERROOT.'/config/mount.json';
}
- $content .= ");\n?>";
+ $content = json_encode($data);
@file_put_contents($file, $content);
}
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 89a9ab29212..cba469e06c4 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -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);