本文整理汇总了PHP中OC_Mount_Config::addMountPoint方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Mount_Config::addMountPoint方法的具体用法?PHP OC_Mount_Config::addMountPoint怎么用?PHP OC_Mount_Config::addMountPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Mount_Config
的用法示例。
在下文中一共展示了OC_Mount_Config::addMountPoint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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)));
示例3: testMultiUserPersonalConfigLoading
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']);
}
示例4:
<?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);
示例5: testMount
/**
* Test mount points used at mount time, making sure
* the configuration is prepared properly.
*
* @dataProvider mountDataProvider
* @param bool $isPersonal true for personal mount point, false for system mount point
* @param string $mountType mount type
* @param string $applicable target user/group or "all"
* @param string $testUser user for which to retrieve the mount points
* @param bool $expectVisible whether to expect the mount point to be visible for $testUser
*/
public function testMount($isPersonal, $mountType, $applicable, $testUser, $expectVisible)
{
$mountConfig = array('host' => 'someost', 'user' => 'someuser', 'password' => 'somepassword', 'root' => 'someroot');
// add mount point as "test" user
$this->assertTrue(OC_Mount_Config::addMountPoint('/ext', '\\OC\\Files\\Storage\\SMB', $mountConfig, $mountType, $applicable, $isPersonal));
// check mount points in the perspective of user $testUser
\OC_User::setUserId($testUser);
$mountPoints = OC_Mount_Config::getAbsoluteMountPoints($testUser);
if ($expectVisible) {
$this->assertEquals(1, count($mountPoints));
$this->assertTrue(isset($mountPoints['/' . self::TEST_USER1 . '/files/ext']));
$this->assertEquals('\\OC\\Files\\Storage\\SMB', $mountPoints['/' . self::TEST_USER1 . '/files/ext']['class']);
$this->assertEquals($mountConfig, $mountPoints['/' . self::TEST_USER1 . '/files/ext']['options']);
} else {
$this->assertEquals(0, count($mountPoints));
}
}
示例6: testPriorityPersistence
/**
* Test for persistence of priority when changing mount options
*/
public function testPriorityPersistence()
{
$class = '\\OC\\Files\\Storage\\SMB';
$priority = 123;
$mountConfig = array('host' => 'somehost', 'user' => 'someuser', 'password' => 'somepassword', 'root' => 'someroot');
$this->assertTrue(OC_Mount_Config::addMountPoint('/ext', $class, $mountConfig, OC_Mount_Config::MOUNT_TYPE_USER, self::TEST_USER1, false, $priority));
// Check for correct priority
$mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
$this->assertEquals($priority, $mountPoints['/' . self::TEST_USER1 . '/files/ext']['priority']);
// Simulate changed mount options (without priority set)
$this->assertTrue(OC_Mount_Config::addMountPoint('/ext', $class, $mountConfig, OC_Mount_Config::MOUNT_TYPE_USER, self::TEST_USER1, false));
// Check for correct priority
$mountPoints = OC_Mount_Config::getAbsoluteMountPoints(self::TEST_USER1);
$this->assertEquals($priority, $mountPoints['/' . self::TEST_USER1 . '/files/ext']['priority']);
}
示例7: testAllowWritingIncompleteConfigIfStorageContructorFails
public function testAllowWritingIncompleteConfigIfStorageContructorFails()
{
$storageClass = 'Test_Mount_Config_Dummy_Storage';
$mountType = 'user';
$applicable = 'all';
$isPersonal = false;
$this->assertEquals(0, OC_Mount_Config::addMountPoint('/ext', $storageClass, array('simulateFail' => true), $mountType, $applicable, $isPersonal));
// config can be retrieved afterwards
$mounts = OC_Mount_Config::getSystemMountPoints();
$this->assertEquals(1, count($mounts));
// no storage id was set
$this->assertFalse(isset($mounts[0]['storage_id']));
}
示例8: saveConfig
/**
* saves mount configuration
*/
private function saveConfig()
{
// we read all mountpoints
$mountPoints = \OC_Mount_Config::getAbsoluteMountPoints(\OCP\User::getUser());
// we use the refresh token as unique ID
$new_refresh_token = json_decode($this->params['hubic_token'], TRUE)['refresh_token'];
foreach ($mountPoints as $mountPoint => $options) {
if ($options['class'] == '\\OC\\Files\\Storage\\Hubic' && json_decode($options['options']['hubic_token'], TRUE)['refresh_token'] == $new_refresh_token) {
$shortMountPoint = end(explode('/', $mountPoint, 4));
if ($options['personal']) {
$mountType = \OC_Mount_Config::MOUNT_TYPE_USER;
$applicable = \OCP\User::getUser();
} else {
$mountType = $options['priority_type'];
$applicable = $options['applicable'];
}
\OC_Mount_Config::addMountPoint($shortMountPoint, $options['class'], $this->params, $mountType, $applicable, $options['personal'], $options['priority']);
break;
}
}
}