Example #1
0
 /**
  * get list of users with access to the file
  *
  * @param string $path to the file
  * @return array
  */
 public function getAccessList($path)
 {
     // Make sure that a share key is generated for the owner too
     list($owner, $ownerPath) = $this->util->getUidAndFilename($path);
     // always add owner to the list of users with access to the file
     $userIds = array($owner);
     if (!$this->util->isFile($ownerPath)) {
         return array('users' => $userIds, 'public' => false);
     }
     $ownerPath = substr($ownerPath, strlen('/files'));
     $ownerPath = $this->util->stripPartialFileExtension($ownerPath);
     // Find out who, if anyone, is sharing the file
     $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner);
     $userIds = \array_merge($userIds, $result['users']);
     $public = $result['public'] || $result['remote'];
     // check if it is a group mount
     if (\OCP\App::isEnabled("files_external")) {
         $mounts = \OC_Mount_Config::getSystemMountPoints();
         foreach ($mounts as $mount) {
             if ($mount['mountpoint'] == substr($ownerPath, 1, strlen($mount['mountpoint']))) {
                 $mountedFor = $this->util->getUserWithAccessToMountPoint($mount['applicable']['users'], $mount['applicable']['groups']);
                 $userIds = array_merge($userIds, $mountedFor);
             }
         }
     }
     // Remove duplicate UIDs
     $uniqueUserIds = array_unique($userIds);
     return array('users' => $uniqueUserIds, 'public' => $public);
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  * Returns the mount points visible for this user.
  *
  * @param array $params
  * @return \OC_OCS_Result share information
  */
 public static function getUserMounts($params)
 {
     $entries = array();
     $user = \OC_User::getUser();
     $mounts = \OC_Mount_Config::getAbsoluteMountPoints($user);
     foreach ($mounts as $mountPoint => $mount) {
         $entries[] = self::formatMount($mountPoint, $mount);
     }
     return new \OC_OCS_Result($entries);
 }
 /**
  * Test mount point validation
  */
 public function testAddMountPointValidation()
 {
     $storageClass = 'Test_Mount_Config_Dummy_Storage';
     $mountType = 'user';
     $applicable = 'all';
     $isPersonal = false;
     $this->assertEquals(false, OC_Mount_Config::addMountPoint('', $storageClass, array(), $mountType, $applicable, $isPersonal));
     $this->assertEquals(false, OC_Mount_Config::addMountPoint('/', $storageClass, array(), $mountType, $applicable, $isPersonal));
     $this->assertEquals(false, OC_Mount_Config::addMountPoint('Shared', $storageClass, array(), $mountType, $applicable, $isPersonal));
     $this->assertEquals(false, OC_Mount_Config::addMountPoint('/Shared', $storageClass, array(), $mountType, $applicable, $isPersonal));
 }
Example #5
0
 /**
  * Intercepts the user credentials on login and stores them
  * encrypted inside the session if SMB_OC storage is enabled.
  * @param array $params
  */
 public static function login($params)
 {
     $mountpoints = \OC_Mount_Config::getAbsoluteMountPoints($params['uid']);
     $mountpointClasses = array();
     foreach ($mountpoints as $mountpoint) {
         $mountpointClasses[$mountpoint['class']] = true;
     }
     if (isset($mountpointClasses['\\OC\\Files\\Storage\\SMB_OC'])) {
         \OC::$server->getSession()->set('smb-credentials', \OC::$server->getCrypto()->encrypt(json_encode($params)));
     }
 }
 /**
  * check if certificate import is allowed
  *
  * @return bool
  */
 protected function isCertificateImportAllowed()
 {
     $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external');
     if ($externalStorageEnabled) {
         $backends = \OC_Mount_Config::getPersonalBackends();
         if (!empty($backends)) {
             return true;
         }
     }
     return false;
 }
Example #7
0
 /**
  * Process storage ready for mounting
  *
  * @param StorageConfig $storage
  * @param IUser $user
  */
 private function prepareStorageConfig(StorageConfig &$storage, IUser $user)
 {
     foreach ($storage->getBackendOptions() as $option => $value) {
         $storage->setBackendOption($option, \OC_Mount_Config::setUserVars($user->getUID(), $value));
     }
     $objectStore = $storage->getBackendOption('objectstore');
     if ($objectStore) {
         $objectClass = $objectStore['class'];
         $storage->setBackendOption('objectstore', new $objectClass($objectStore));
     }
     $storage->getAuthMechanism()->manipulateStorageConfig($storage);
     $storage->getBackend()->manipulateStorageConfig($storage);
 }
 /**
  * Validate storage config
  *
  * @param StorageConfig $storage storage config
  *
  * @return DataResponse|null returns response in case of validation error
  */
 protected function validate(StorageConfig $storage)
 {
     $result = parent::validate($storage);
     if ($result != null) {
         return $result;
     }
     // Verify that the mount point applies for the current user
     // Prevent non-admin users from mounting local storage and other disabled backends
     $allowedBackends = \OC_Mount_Config::getPersonalBackends();
     if (!isset($allowedBackends[$storage->getBackendClass()])) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Invalid storage backend "%s"', array($storage->getBackendClass()))), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     return null;
 }
Example #9
0
 /**
  * Process storage ready for mounting
  *
  * @param StorageConfig $storage
  * @param IUser $user
  */
 private function prepareStorageConfig(StorageConfig &$storage, IUser $user)
 {
     foreach ($storage->getBackendOptions() as $option => $value) {
         $storage->setBackendOption($option, \OC_Mount_Config::setUserVars($user->getUID(), $value));
     }
     $objectStore = $storage->getBackendOption('objectstore');
     if ($objectStore) {
         $objectClass = $objectStore['class'];
         if (!is_subclass_of($objectClass, '\\OCP\\Files\\ObjectStore\\IObjectStore')) {
             throw new \InvalidArgumentException('Invalid object store');
         }
         $storage->setBackendOption('objectstore', new $objectClass($objectStore));
     }
     $storage->getAuthMechanism()->manipulateStorageConfig($storage);
     $storage->getBackend()->manipulateStorageConfig($storage);
 }
Example #10
0
 /**
  * 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);
 }
Example #11
0
 /**
  * Get all mountpoints applicable for the user
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $loader
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $loader)
 {
     $mountPoints = \OC_Mount_Config::getAbsoluteMountPoints($user->getUID());
     $mounts = array();
     foreach ($mountPoints as $mountPoint => $options) {
         if (isset($options['options']['objectstore'])) {
             $objectClass = $options['options']['objectstore']['class'];
             $options['options']['objectstore'] = new $objectClass($options['options']['objectstore']);
         }
         $mountOptions = isset($options['mountOptions']) ? $options['mountOptions'] : [];
         if (isset($options['personal']) && $options['personal']) {
             $mounts[] = new PersonalMount($options['class'], $mountPoint, $options['options'], $loader, $mountOptions);
         } else {
             $mounts[] = new MountPoint($options['class'], $mountPoint, $options['options'], $loader, $mountOptions);
         }
     }
     return $mounts;
 }
<?php

OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::callCheck();
if ($_POST['isPersonal'] == 'true') {
    OCP\JSON::checkLoggedIn();
    $isPersonal = true;
} else {
    OCP\JSON::checkAdminUser();
    $isPersonal = false;
}
$mountPoint = (string) $_POST['mountPoint'];
$oldMountPoint = (string) $_POST['oldMountPoint'];
$class = (string) $_POST['class'];
$options = (string) $_POST['classOptions'];
$type = (string) $_POST['mountType'];
$applicable = (string) $_POST['applicable'];
if ($oldMountPoint and $oldMountPoint !== $mountPoint) {
    OC_Mount_Config::removeMountPoint($oldMountPoint, $type, $applicable, $isPersonal);
}
$status = OC_Mount_Config::addMountPoint($mountPoint, $class, $options, $type, $applicable, $isPersonal);
OCP\JSON::success(array('data' => array('message' => $status)));
 /**
  * Read legacy config data
  *
  * @return array list of storage configs
  */
 protected function readLegacyConfig()
 {
     // read user config
     $user = $this->userSession->getUser()->getUID();
     return \OC_Mount_Config::readData($user);
 }
 /**
  * Read legacy config data
  *
  * @return array list of mount configs
  */
 protected function readLegacyConfig()
 {
     // read global config
     return \OC_Mount_Config::readData();
 }
Example #15
0
 public function tearDown()
 {
     \OC_Mount_Config::$skipTest = false;
     self::$hookCalls = array();
     if ($this->dbConfig) {
         $this->dbConfig->clean();
     }
 }
Example #16
0
 /**
  * Check whether the given storage is available / valid.
  *
  * Note that this operation can be time consuming depending
  * on whether the remote storage is available or not.
  *
  * @param StorageConfig $storage storage configuration
  */
 protected function updateStorageStatus(StorageConfig &$storage)
 {
     try {
         /** @var AuthMechanism */
         $authMechanism = $storage->getAuthMechanism();
         $authMechanism->manipulateStorageConfig($storage);
         /** @var Backend */
         $backend = $storage->getBackend();
         $backend->manipulateStorageConfig($storage);
         // update status (can be time-consuming)
         $storage->setStatus(\OC_Mount_Config::getBackendStatus($backend->getStorageClass(), $storage->getBackendOptions(), false));
     } catch (InsufficientDataForMeaningfulAnswerException $e) {
         $storage->setStatus(\OC_Mount_Config::STATUS_INDETERMINATE, $this->l10n->t('Insufficient data: %s', [$e->getMessage()]));
     } catch (StorageNotAvailableException $e) {
         $storage->setStatus(\OC_Mount_Config::STATUS_ERROR, $e->getMessage());
     } catch (\Exception $e) {
         // FIXME: convert storage exceptions to StorageNotAvailableException
         $storage->setStatus(\OC_Mount_Config::STATUS_ERROR, get_class($e) . ': ' . $e->getMessage());
     }
 }
Example #17
0
 /**
  * check if the file is stored on a system wide mount point
  * @param string $path relative to /data/user with leading '/'
  * @return boolean
  */
 public function isSystemWideMountPoint($path)
 {
     $normalizedPath = ltrim($path, '/');
     if (\OCP\App::isEnabled("files_external")) {
         $mounts = \OC_Mount_Config::getSystemMountPoints();
         foreach ($mounts as $mount) {
             if ($mount['mountpoint'] == substr($normalizedPath, 0, strlen($mount['mountpoint']))) {
                 if ($this->isMountPointApplicableToUser($mount)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Example #18
0
 public function tearDown()
 {
     \OC_Mount_Config::$skipTest = false;
     self::$hookCalls = array();
 }
Example #19
0
<?php

OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::callCheck();
if ($_POST['isPersonal'] == 'true') {
    OCP\JSON::checkLoggedIn();
    $isPersonal = true;
} else {
    OCP\JSON::checkAdminUser();
    $isPersonal = false;
}
OC_Mount_Config::addMountPoint($_POST['mountPoint'], $_POST['class'], $_POST['classOptions'], $_POST['mountType'], $_POST['applicable'], $isPersonal);
Example #20
0
 /**
  * check if the file is stored on a system wide mount point
  * @param string $path relative to /data/user with leading '/'
  * @param string $uid
  * @return boolean
  */
 public function isSystemWideMountPoint($path, $uid)
 {
     if (\OCP\App::isEnabled("files_external")) {
         $mounts = \OC_Mount_Config::getSystemMountPoints();
         foreach ($mounts as $mount) {
             if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
                 if ($this->isMountPointApplicableToUser($mount, $uid)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Example #21
0
    } else {
        $languages[] = $ln;
    }
}
ksort($commonlanguages);
// sort now by displayed language not the iso-code
usort($languages, function ($a, $b) {
    return strcmp($a['name'], $b['name']);
});
//links to clients
$clients = array('desktop' => $config->getSystemValue('customclient_desktop', $defaults->getSyncClientUrl()), 'android' => $config->getSystemValue('customclient_android', $defaults->getAndroidClientUrl()), 'ios' => $config->getSystemValue('customclient_ios', $defaults->getiOSClientUrl()));
// only show root certificate import if external storages are enabled
$enableCertImport = false;
$externalStorageEnabled = \OC::$server->getAppManager()->isEnabledForUser('files_external');
if ($externalStorageEnabled) {
    $backends = OC_Mount_Config::getPersonalBackends();
    if (!empty($backends)) {
        $enableCertImport = true;
    }
}
// Return template
$tmpl = new OC_Template('settings', 'personal', 'user');
$tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
$tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
$tmpl->assign('usage_relative', $storageInfo['relative']);
$tmpl->assign('clients', $clients);
$tmpl->assign('email', $email);
$tmpl->assign('languages', $languages);
$tmpl->assign('commonlanguages', $commonlanguages);
$tmpl->assign('activelanguage', $userLang);
$tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
<?php

OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$view = \OCP\Files::getStorage("files_external");
$file = 'uploads/' . ltrim($_POST['cert'], "/\\.");
if ($view->file_exists($file)) {
    $view->unlink($file);
    OC_Mount_Config::createCertificateBundle();
}
Example #23
0
 public function testMultiUserPersonalConfigLoading()
 {
     $mountConfig = array('host' => 'somehost', 'user' => 'someuser', 'password' => 'somepassword', 'root' => 'someroot');
     // Create personal mount point
     $this->assertTrue(OC_Mount_Config::addMountPoint('/ext', '\\OC\\Files\\Storage\\SMB', $mountConfig, OC_Mount_Config::MOUNT_TYPE_USER, self::TEST_USER1, true));
     // Ensure other user can read mount points
     \OC_User::setUserId(self::TEST_USER2);
     $mountPointsMe = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER2);
     $mountPointsOther = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
     $this->assertEquals(0, count($mountPointsMe));
     $this->assertEquals(1, count($mountPointsOther));
     $this->assertTrue(isset($mountPointsOther['/' . self::TEST_USER1 . '/files/ext']));
     $this->assertEquals('\\OC\\Files\\Storage\\SMB', $mountPointsOther['/' . self::TEST_USER1 . '/files/ext']['class']);
     $this->assertEquals($mountConfig, $mountPointsOther['/' . self::TEST_USER1 . '/files/ext']['options']);
 }
Example #24
0
 private static function generateDependencyMessage($dependencies)
 {
     $l = new \OC_L10N('files_external');
     $dependencyMessage = '';
     foreach ($dependencies as $module => $backends) {
         $dependencyGroup = array();
         foreach ($backends as $backend) {
             if (is_array($backend)) {
                 $dependencyMessage .= '<br />' . $l->t('<b>Note:</b> ') . $backend['message'];
             } else {
                 $dependencyGroup[] = $backend;
             }
         }
         $dependencyGroupCount = count($dependencyGroup);
         if ($dependencyGroupCount > 0) {
             $backends = '';
             for ($i = 0; $i < $dependencyGroupCount; $i++) {
                 if ($i > 0 && $i === $dependencyGroupCount - 1) {
                     $backends .= $l->t(' and ');
                 } elseif ($i > 0) {
                     $backends .= ', ';
                 }
                 $backends .= '<i>' . $dependencyGroup[$i] . '</i>';
             }
             $dependencyMessage .= '<br />' . OC_Mount_Config::getSingleDependencyMessage($l, $module, $backends);
         }
     }
     return $dependencyMessage;
 }
Example #25
0
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/
OC_Util::checkAdminUser();
OCP\Util::addScript('files_external', 'settings');
OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min');
OCP\Util::addStyle('files_external', 'settings');
OCP\Util::addStyle('3rdparty', 'chosen/chosen');
$backends = OC_Mount_Config::getBackends();
$personal_backends = array();
$enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
foreach ($backends as $class => $backend) {
    if ($class != '\\OC\\Files\\Storage\\Local') {
        $personal_backends[$class] = array('backend' => $backend['backend'], 'enabled' => in_array($class, $enabled_backends));
    }
}
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', true);
$tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints());
$tmpl->assign('backends', $backends);
$tmpl->assign('personal_backends', $personal_backends);
$tmpl->assign('groups', OC_Group::getGroups());
$tmpl->assign('users', OCP\User::getUsers());
$tmpl->assign('userDisplayNames', OC_User::getDisplayNames());
$tmpl->assign('dependencies', OC_Mount_Config::checkDependencies());
$tmpl->assign('allowUserMounting', OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes'));
return $tmpl->fetchPage();
Example #26
0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
use OCA\Files_External\Service\BackendService;
\OCP\User::checkAdminUser();
// we must use the same container
$appContainer = \OC_Mount_Config::$app->getContainer();
$backendService = $appContainer->query('OCA\\Files_External\\Service\\BackendService');
$globalStoragesService = $appContainer->query('OCA\\Files_external\\Service\\GlobalStoragesService');
\OC_Util::addVendorScript('select2/select2');
\OC_Util::addVendorStyle('select2/select2');
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
$tmpl->assign('visibilityType', BackendService::VISIBILITY_ADMIN);
$tmpl->assign('storages', $globalStoragesService->getStorages());
$tmpl->assign('backends', $backendService->getAvailableBackends());
$tmpl->assign('authMechanisms', $backendService->getAuthMechanisms());
$tmpl->assign('dependencies', OC_Mount_Config::dependencyMessage($backendService->getBackends()));
$tmpl->assign('allowUserMounting', $backendService->isUserMountingAllowed());
return $tmpl->fetchPage();
 /**
  * Read the external storages config
  *
  * @return StorageConfig[] map of storage id to storage config
  */
 public function getAllStorages()
 {
     $mountPoints = $this->readLegacyConfig();
     /**
      * Here is the how the horribly messy mount point array looks like
      * from the mount.json file:
      *
      * $storageOptions = $mountPoints[$mountType][$applicable][$mountPath]
      *
      * - $mountType is either "user" or "group"
      * - $applicable is the name of a user or group (or the current user for personal mounts)
      * - $mountPath is the mount point path (where the storage must be mounted)
      * - $storageOptions is a map of storage options:
      *     - "priority": storage priority
      *     - "backend": backend identifier
      *     - "class": LEGACY backend class name
      *     - "options": backend-specific options
      *     - "authMechanism": authentication mechanism identifier
      *     - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
      */
     // group by storage id
     /** @var StorageConfig[] $storages */
     $storages = [];
     // for storages without id (legacy), group by config hash for
     // later processing
     $storagesWithConfigHash = [];
     foreach ($mountPoints as $mountType => $applicables) {
         foreach ($applicables as $applicable => $mountPaths) {
             foreach ($mountPaths as $rootMountPath => $storageOptions) {
                 $currentStorage = null;
                 /**
                  * Flag whether the config that was read already has an id.
                  * If not, it will use a config hash instead and generate
                  * a proper id later
                  *
                  * @var boolean
                  */
                 $hasId = false;
                 // the root mount point is in the format "/$user/files/the/mount/point"
                 // we remove the "/$user/files" prefix
                 $parts = explode('/', ltrim($rootMountPath, '/'), 3);
                 if (count($parts) < 3) {
                     // something went wrong, skip
                     \OCP\Util::writeLog('files_external', 'Could not parse mount point "' . $rootMountPath . '"', \OCP\Util::ERROR);
                     continue;
                 }
                 $relativeMountPath = rtrim($parts[2], '/');
                 // note: we cannot do this after the loop because the decrypted config
                 // options might be needed for the config hash
                 $storageOptions['options'] = \OC_Mount_Config::decryptPasswords($storageOptions['options']);
                 if (!isset($storageOptions['backend'])) {
                     $storageOptions['backend'] = $storageOptions['class'];
                     // legacy compat
                 }
                 if (!isset($storageOptions['authMechanism'])) {
                     $storageOptions['authMechanism'] = null;
                     // ensure config hash works
                 }
                 if (isset($storageOptions['id'])) {
                     $configId = (int) $storageOptions['id'];
                     if (isset($storages[$configId])) {
                         $currentStorage = $storages[$configId];
                     }
                     $hasId = true;
                 } else {
                     // missing id in legacy config, need to generate
                     // but at this point we don't know the max-id, so use
                     // first group it by config hash
                     $storageOptions['mountpoint'] = $rootMountPath;
                     $configId = \OC_Mount_Config::makeConfigHash($storageOptions);
                     if (isset($storagesWithConfigHash[$configId])) {
                         $currentStorage = $storagesWithConfigHash[$configId];
                     }
                 }
                 if (is_null($currentStorage)) {
                     // create new
                     $currentStorage = new StorageConfig($configId);
                     $currentStorage->setMountPoint($relativeMountPath);
                 }
                 try {
                     $this->populateStorageConfigWithLegacyOptions($currentStorage, $mountType, $applicable, $storageOptions);
                     if ($hasId) {
                         $storages[$configId] = $currentStorage;
                     } else {
                         $storagesWithConfigHash[$configId] = $currentStorage;
                     }
                 } catch (\UnexpectedValueException $e) {
                     // don't die if a storage backend doesn't exist
                     \OCP\Util::writeLog('files_external', 'Could not load storage: "' . $e->getMessage() . '"', \OCP\Util::ERROR);
                 }
             }
         }
     }
     // convert parameter values
     foreach ($storages as $storage) {
         $storage->getBackend()->validateStorageDefinition($storage);
         $storage->getAuthMechanism()->validateStorageDefinition($storage);
     }
     return $storages;
 }
Example #28
0
File: app.php Project: kenwi/core
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OC::$CLASSPATH['OC\\Files\\Storage\\StreamWrapper'] = 'files_external/lib/streamwrapper.php';
OC::$CLASSPATH['OC\\Files\\Storage\\FTP'] = 'files_external/lib/ftp.php';
OC::$CLASSPATH['OC\\Files\\Storage\\OwnCloud'] = 'files_external/lib/owncloud.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Google'] = 'files_external/lib/google.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Swift'] = 'files_external/lib/swift.php';
OC::$CLASSPATH['OC\\Files\\Storage\\SMB'] = 'files_external/lib/smb.php';
OC::$CLASSPATH['OC\\Files\\Storage\\AmazonS3'] = 'files_external/lib/amazons3.php';
OC::$CLASSPATH['OC\\Files\\Storage\\Dropbox'] = 'files_external/lib/dropbox.php';
OC::$CLASSPATH['OC\\Files\\Storage\\SFTP'] = 'files_external/lib/sftp.php';
OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php';
OC::$CLASSPATH['OCA\\Files\\External\\Api'] = 'files_external/lib/api.php';
require_once __DIR__ . '/../3rdparty/autoload.php';
// register Application object singleton
\OC_Mount_Config::$app = new \OCA\Files_external\Appinfo\Application();
$appContainer = \OC_Mount_Config::$app->getContainer();
\OC_Mount_Config::$app->registerSettings();
$l = \OC::$server->getL10N('files_external');
\OCA\Files\App::getNavigationManager()->add(["id" => 'extstoragemounts', "appname" => 'files_external', "script" => 'list.php', "order" => 30, "name" => $l->t('External storage')]);
$mountProvider = $appContainer->query('OCA\\Files_External\\Config\\ConfigAdapter');
\OC::$server->getMountProviderCollection()->registerProvider($mountProvider);
Example #29
0
 /**
  * Get backend dependency message
  * TODO: move into AppFramework along with templates
  *
  * @param Backend[] $backends
  * @return string
  */
 public static function dependencyMessage($backends)
 {
     $l = \OC::$server->getL10N('files_external');
     $message = '';
     $dependencyGroups = [];
     foreach ($backends as $backend) {
         foreach ($backend->checkDependencies() as $dependency) {
             if ($message = $dependency->getMessage()) {
                 $message .= '<br />' . $l->t('<b>Note:</b> ') . $message;
             } else {
                 $dependencyGroups[$dependency->getDependency()][] = $backend;
             }
         }
     }
     foreach ($dependencyGroups as $module => $dependants) {
         $backends = implode(', ', array_map(function ($backend) {
             return '<i>' . $backend->getText() . '</i>';
         }, $dependants));
         $message .= '<br />' . OC_Mount_Config::getSingleDependencyMessage($l, $module, $backends);
     }
     return $message;
 }
Example #30
0
 public function tearDown()
 {
     \OC_Mount_Config::$skipTest = false;
 }