diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2014-05-13 00:14:30 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2014-05-13 00:14:30 +0100 |
commit | 08a8a409d64051f3d20e6ea8ba1507f144a1b30d (patch) | |
tree | 82910d8fae9008248dbe966777f1af12a3887b90 /apps/files_external | |
parent | 408189b7e48ba3a738339ed3cb5fe6e376a8c94b (diff) | |
download | nextcloud-server-08a8a409d64051f3d20e6ea8ba1507f144a1b30d.tar.gz nextcloud-server-08a8a409d64051f3d20e6ea8ba1507f144a1b30d.zip |
Extract mount point merging logic into separate function
Diffstat (limited to 'apps/files_external')
-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() { |