diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-02-18 14:56:25 -0800 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-02-18 14:56:25 -0800 |
commit | d9035d4fdc6b5363c1a5b96a8ba8b6f387a0eafb (patch) | |
tree | 6b130dc252b7b48800c64a681d6aea13e40e4a2d /apps/files_external | |
parent | 474b82931b44af08642403ac06f22b4ecfc056b1 (diff) | |
parent | 3bf9aa408e4fb3f20dc715ad43b7a6aaaa6fb4f4 (diff) | |
download | nextcloud-server-d9035d4fdc6b5363c1a5b96a8ba8b6f387a0eafb.tar.gz nextcloud-server-d9035d4fdc6b5363c1a5b96a8ba8b6f387a0eafb.zip |
Merge pull request #1728 from owncloud/mountconfig
Use json for new mount configuration files
Diffstat (limited to 'apps/files_external')
-rwxr-xr-x | apps/files_external/lib/config.php | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index a3d1da68845..3f08610b2b8 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -279,13 +279,21 @@ class OC_Mount_Config { * @return array */ 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 = include $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; } @@ -300,39 +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, JSON_PRETTY_PRINT); @file_put_contents($file, $content); } |