summaryrefslogtreecommitdiffstats
path: root/apps
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 /apps
parent46626915ef6888c958111b259ae6c0d3729b5198 (diff)
downloadnextcloud-server-6da2c6c83e48fc3c7f8dd0814fe815d2b772f6eb.tar.gz
nextcloud-server-6da2c6c83e48fc3c7f8dd0814fe815d2b772f6eb.zip
Create new mountconfig files in json
Diffstat (limited to 'apps')
-rwxr-xr-xapps/files_external/lib/config.php45
1 files changed, 14 insertions, 31 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);
}