24993280ed
Beside some small improvements and bug fixes this will probably the final state for OC8. To test this you need to set up two ownCloud instances. Let's say: URL: myPC/firstOwnCloud user: user1 URL: myPC/secondOwnCloud user: user2 Now user1 can share a file with user2 by entering the username and the URL to the second ownCloud to the share-drop-down, in this case "user2@myPC/secondOwnCloud". The next time user2 login he will get a notification that he received a server-to-server share with the option to accept/decline it. If he accept it the share will be mounted. In both cases a event will be send back to user1 and add a notification to the activity stream that the share was accepted/declined. If user1 decides to unshare the file again from user2 the share will automatically be removed from the second ownCloud server and user2 will see a notification in his activity stream that user1@myPC/firstOwnCloud has unshared the file/folder from him.
61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
* later.
|
|
* See the COPYING-README file.
|
|
*/
|
|
|
|
OCP\JSON::callCheck();
|
|
OCP\JSON::checkLoggedIn();
|
|
OCP\JSON::checkAppEnabled('files_sharing');
|
|
|
|
$l = \OC::$server->getL10N('files_sharing');
|
|
|
|
// check if server admin allows to mount public links from other servers
|
|
if (OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled() === false) {
|
|
\OCP\JSON::error(array('data' => array('message' => $l->t('Server to server sharing is not enabled on this server'))));
|
|
exit();
|
|
}
|
|
|
|
$token = $_POST['token'];
|
|
$remote = $_POST['remote'];
|
|
$owner = $_POST['owner'];
|
|
$name = $_POST['name'];
|
|
$password = $_POST['password'];
|
|
|
|
// Check for invalid name
|
|
if(!\OCP\Util::isValidFileName($name)) {
|
|
\OCP\JSON::error(array('data' => array('message' => $l->t('The mountpoint name contains invalid characters.'))));
|
|
exit();
|
|
}
|
|
|
|
$externalManager = new \OCA\Files_Sharing\External\Manager(
|
|
\OC::$server->getDatabaseConnection(),
|
|
\OC\Files\Filesystem::getMountManager(),
|
|
\OC\Files\Filesystem::getLoader(),
|
|
\OC::$server->getUserSession(),
|
|
\OC::$server->getHTTPHelper()
|
|
);
|
|
|
|
$name = OCP\Files::buildNotExistingFileName('/', $name);
|
|
|
|
// check for ssl cert
|
|
if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
|
|
\OCP\JSON::error(array('data' => array('message' => $l->t("Invalid or untrusted SSL certificate"))));
|
|
exit;
|
|
} else {
|
|
$mount = $externalManager->addShare($remote, $token, $password, $name, $owner, true);
|
|
/**
|
|
* @var \OCA\Files_Sharing\External\Storage $storage
|
|
*/
|
|
$storage = $mount->getStorage();
|
|
$result = $storage->file_exists('');
|
|
if ($result) {
|
|
$storage->getScanner()->scanAll();
|
|
\OCP\JSON::success();
|
|
} else {
|
|
$externalManager->removeShare($mount->getMountPoint());
|
|
\OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't add remote share"))));
|
|
}
|
|
}
|