diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-05-13 12:19:41 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-05-13 12:19:41 +0200 |
commit | 6d00675d694c0d8ec7bf451ae5eb938ac6ff363c (patch) | |
tree | 2d6fb450b8814e837a262fc80c96da1bae82ad40 | |
parent | 22e57d7e5a605f65571e73393c9c53a2d089e92a (diff) | |
parent | 08a8a409d64051f3d20e6ea8ba1507f144a1b30d (diff) | |
download | nextcloud-server-6d00675d694c0d8ec7bf451ae5eb938ac6ff363c.tar.gz nextcloud-server-6d00675d694c0d8ec7bf451ae5eb938ac6ff363c.zip |
Merge pull request #8562 from owncloud/better-addmountpoint
Extract mount point merging logic into separate function
-rwxr-xr-x | apps/files_external/lib/config.php | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 15fbda927e0..9906b7670a8 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -400,19 +400,11 @@ class OC_Mount_Config { 'options' => self::encryptPasswords($classOptions)) ) ); + $mountPoints = self::readData($isPersonal ? OCP\User::getUser() : NULL); - // Merge the new mount point into the current mount points - if (isset($mountPoints[$mountType])) { - if (isset($mountPoints[$mountType][$applicable])) { - $mountPoints[$mountType][$applicable] - = array_merge($mountPoints[$mountType][$applicable], $mount[$applicable]); - } else { - $mountPoints[$mountType] = array_merge($mountPoints[$mountType], $mount); - } - } else { - $mountPoints[$mountType] = $mount; - } + $mountPoints = self::mergeMountPoints($mountPoints, $mount, $mountType); self::writeData($isPersonal ? OCP\User::getUser() : NULL, $mountPoints); + return self::getBackendStatus($class, $classOptions, $isPersonal); } @@ -690,6 +682,28 @@ class OC_Mount_Config { } /** + * Merges mount points + * @param array $data Existing mount points + * @param array $mountPoint New mount point + * @param string $mountType + * @return array + */ + private static function mergeMountPoints($data, $mountPoint, $mountType) { + $applicable = key($mountPoint); + if (isset($data[$mountType])) { + if (isset($data[$mountType][$applicable])) { + $data[$mountType][$applicable] + = array_merge($data[$mountType][$applicable], $mountPoint[$applicable]); + } else { + $data[$mountType] = array_merge($data[$mountType], $mountPoint); + } + } else { + $data[$mountType] = $mountPoint; + } + return $data; + } + + /** * Returns the encryption cipher */ private static function getCipher() { |