/** * Write the storages to the configuration. * * @param array $storages map of storage id to storage config */ public function writeConfig($storages) { // let the horror begin $mountPoints = []; foreach ($storages as $storageConfig) { $mountPoint = $storageConfig->getMountPoint(); $oldBackendOptions = $storageConfig->getBackendOptions(); $storageConfig->setBackendOptions(\OC_Mount_Config::encryptPasswords($oldBackendOptions)); // system mount $rootMountPoint = '/$user/files/' . ltrim($mountPoint, '/'); $applicableUsers = $storageConfig->getApplicableUsers(); $applicableGroups = $storageConfig->getApplicableGroups(); foreach ($applicableUsers as $applicable) { $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_USER, $applicable, $rootMountPoint, $storageConfig); } foreach ($applicableGroups as $applicable) { $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_GROUP, $applicable, $rootMountPoint, $storageConfig); } // if neither "applicableGroups" or "applicableUsers" were set, use "all" user if (empty($applicableUsers) && empty($applicableGroups)) { $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_USER, 'all', $rootMountPoint, $storageConfig); } // restore old backend options where the password was not encrypted, // because we don't want to change the state of the original object $storageConfig->setBackendOptions($oldBackendOptions); } \OC_Mount_Config::writeData(null, $mountPoints); }
/** * Write the storages to the user's configuration. * * @param array $storages map of storage id to storage config */ public function writeConfig($storages) { $user = $this->userSession->getUser()->getUID(); // let the horror begin $mountPoints = []; foreach ($storages as $storageConfig) { $mountPoint = $storageConfig->getMountPoint(); $oldBackendOptions = $storageConfig->getBackendOptions(); $storageConfig->setBackendOptions(\OC_Mount_Config::encryptPasswords($oldBackendOptions)); $rootMountPoint = '/' . $user . '/files/' . ltrim($mountPoint, '/'); $this->addMountPoint($mountPoints, \OC_Mount_Config::MOUNT_TYPE_USER, $user, $rootMountPoint, $storageConfig); // restore old backend options where the password was not encrypted, // because we don't want to change the state of the original object $storageConfig->setBackendOptions($oldBackendOptions); } \OC_Mount_Config::writeData($user, $mountPoints); }
/** * Write legacy config data * * @param array $mountPoints */ protected function writeLegacyConfig(array $mountPoints) { // write global config \OC_Mount_Config::writeData(null, $mountPoints); }
/** * Write legacy config data * * @param array $mountPoints */ protected function writeLegacyConfig(array $mountPoints) { // write user config $user = $this->getUser()->getUID(); \OC_Mount_Config::writeData($user, $mountPoints); }