<?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)));
public function testHooks() { $mountPoint = '/test'; $mountType = 'user'; $applicable = 'all'; $isPersonal = false; $mountConfig = array('host' => 'smbhost', 'user' => 'smbuser', 'password' => 'smbpassword', 'share' => 'smbshare', 'root' => 'smbroot'); // write config $this->assertTrue(OC_Mount_Config::addMountPoint($mountPoint, '\\OC\\Files\\Storage\\SMB', $mountConfig, $mountType, $applicable, $isPersonal)); list($hookName, $params) = Test_Mount_Config_Hook_Test::getLastCall(); $this->assertEquals(\OC\Files\Filesystem::signal_create_mount, $hookName); $this->assertEquals($mountPoint, $params[\OC\Files\Filesystem::signal_param_path]); $this->assertEquals($mountType, $params[\OC\Files\Filesystem::signal_param_mount_type]); $this->assertEquals($applicable, $params[\OC\Files\Filesystem::signal_param_users]); Test_Mount_Config_Hook_Test::clear(); // edit $mountConfig['host'] = 'anothersmbhost'; $this->assertTrue(OC_Mount_Config::addMountPoint($mountPoint, '\\OC\\Files\\Storage\\SMB', $mountConfig, $mountType, $applicable, $isPersonal)); // hook must not be called on edit list($hookName, $params) = Test_Mount_Config_Hook_Test::getLastCall(); $this->assertEquals(null, $hookName); Test_Mount_Config_Hook_Test::clear(); $this->assertTrue(OC_Mount_Config::removeMountPoint($mountPoint, $mountType, $applicable, $isPersonal)); list($hookName, $params) = Test_Mount_Config_Hook_Test::getLastCall(); $this->assertEquals(\OC\Files\Filesystem::signal_delete_mount, $hookName); $this->assertEquals($mountPoint, $params[\OC\Files\Filesystem::signal_param_path]); $this->assertEquals($mountType, $params[\OC\Files\Filesystem::signal_param_mount_type]); $this->assertEquals($applicable, $params[\OC\Files\Filesystem::signal_param_users]); }
<?php OCP\JSON::checkAppEnabled('files_external'); OCP\JSON::callCheck(); if (!isset($_POST['isPersonal'])) { return; } if (!isset($_POST['mountPoint'])) { return; } if (!isset($_POST['mountType'])) { return; } if (!isset($_POST['applicable'])) { return; } if ($_POST['isPersonal'] == 'true') { OCP\JSON::checkLoggedIn(); $isPersonal = true; } else { OCP\JSON::checkAdminUser(); $isPersonal = false; } OC_Mount_Config::removeMountPoint((string) $_POST['mountPoint'], (string) $_POST['mountType'], (string) $_POST['applicable'], $isPersonal);
/** * Remove the mount points * * @return bool */ public function removeMount() { $user = \OCP\User::getUser(); $relativeMountPoint = substr($this->getMountPoint(), strlen('/' . $user . '/files/')); return \OC_Mount_Config::removeMountPoint($relativeMountPoint, \OC_Mount_Config::MOUNT_TYPE_USER, $user, true); }