本文整理汇总了PHP中OC_Mount_Config类的典型用法代码示例。如果您正苦于以下问题:PHP OC_Mount_Config类的具体用法?PHP OC_Mount_Config怎么用?PHP OC_Mount_Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_Mount_Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAccessList
/**
* 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);
}
示例2: writeConfig
/**
* 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);
}
示例3: getUserMounts
/**
* 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);
}
示例4: testAddMountPointValidation
/**
* 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));
}
示例5: login
/**
* 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)));
}
}
示例6: isCertificateImportAllowed
/**
* 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;
}
示例7: prepareStorageConfig
/**
* 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);
}
示例8: validate
/**
* 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;
}
示例9: prepareStorageConfig
/**
* 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);
}
示例10: writeConfig
/**
* 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);
}
示例11: getMountsForUser
/**
* 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;
}
示例12: array
<?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)));
示例13: readLegacyConfig
/**
* 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);
}
示例14: readLegacyConfig
/**
* Read legacy config data
*
* @return array list of mount configs
*/
protected function readLegacyConfig()
{
// read global config
return \OC_Mount_Config::readData();
}
示例15: tearDown
public function tearDown()
{
\OC_Mount_Config::$skipTest = false;
self::$hookCalls = array();
if ($this->dbConfig) {
$this->dbConfig->clean();
}
}