move federated sharing settings to the federatedfilesharing app
|
@ -55,7 +55,9 @@ $linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
|
|||
|
||||
$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin) {
|
||||
$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
|
||||
if (OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
|
||||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
|
||||
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
|
||||
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
|
||||
// this is what is thrown when trying to access a non-existing share
|
||||
throw new \Sabre\DAV\Exception\NotAuthenticated();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,5 @@
|
|||
|
||||
namespace OCA\FederatedFileSharing\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
|
||||
new App('federatedfilesharing');
|
||||
|
||||
$app = new Application('federatedfilesharing');
|
||||
$app->registerSettings();
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* @author Björn Schießle <schiessle@owncloud.com>
|
||||
*
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
* @license AGPL-3.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/>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace OCA\FederatedFileSharing\AppInfo;
|
||||
|
||||
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCP\AppFramework\App;
|
||||
|
||||
class Application extends App {
|
||||
|
||||
/** @var FederatedShareProvider */
|
||||
protected $federatedShareProvider;
|
||||
|
||||
/**
|
||||
* register personal and admin settings page
|
||||
*/
|
||||
public function registerSettings() {
|
||||
\OCP\App::registerAdmin('federatedfilesharing', 'settings-admin');
|
||||
\OCP\App::registerPersonal('federatedfilesharing', 'settings-personal');
|
||||
}
|
||||
|
||||
/**
|
||||
* get instance of federated share provider
|
||||
*
|
||||
* @return FederatedShareProvider
|
||||
*/
|
||||
public function getFederatedShareProvider() {
|
||||
if ($this->federatedShareProvider === null) {
|
||||
$this->initFederatedShareProvider();
|
||||
}
|
||||
return $this->federatedShareProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize federated share provider
|
||||
*/
|
||||
protected function initFederatedShareProvider() {
|
||||
$addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
|
||||
\OC::$server->getURLGenerator(),
|
||||
\OC::$server->getL10N('federatedfilesharing')
|
||||
);
|
||||
$discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
|
||||
\OC::$server->getMemCacheFactory(),
|
||||
\OC::$server->getHTTPClientService()
|
||||
);
|
||||
$notifications = new \OCA\FederatedFileSharing\Notifications(
|
||||
$addressHandler,
|
||||
\OC::$server->getHTTPClientService(),
|
||||
$discoveryManager,
|
||||
\OC::$server->getJobList()
|
||||
);
|
||||
$tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
|
||||
\OC::$server->getSecureRandom()
|
||||
);
|
||||
|
||||
$this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
$addressHandler,
|
||||
$notifications,
|
||||
$tokenHandler,
|
||||
\OC::$server->getL10N('federatedfilesharing'),
|
||||
\OC::$server->getLogger(),
|
||||
\OC::$server->getLazyRootFolder(),
|
||||
\OC::$server->getConfig()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
@ -25,6 +25,8 @@ namespace OCA\FederatedFileSharing;
|
|||
|
||||
use OC\Share20\Share;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
use OCP\Share\IShare;
|
||||
|
@ -65,6 +67,9 @@ class FederatedShareProvider implements IShareProvider {
|
|||
/** @var IRootFolder */
|
||||
private $rootFolder;
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* DefaultShareProvider constructor.
|
||||
*
|
||||
|
@ -75,6 +80,7 @@ class FederatedShareProvider implements IShareProvider {
|
|||
* @param IL10N $l10n
|
||||
* @param ILogger $logger
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param IConfig $config
|
||||
*/
|
||||
public function __construct(
|
||||
IDBConnection $connection,
|
||||
|
@ -83,7 +89,8 @@ class FederatedShareProvider implements IShareProvider {
|
|||
TokenHandler $tokenHandler,
|
||||
IL10N $l10n,
|
||||
ILogger $logger,
|
||||
IRootFolder $rootFolder
|
||||
IRootFolder $rootFolder,
|
||||
IConfig $config
|
||||
) {
|
||||
$this->dbConnection = $connection;
|
||||
$this->addressHandler = $addressHandler;
|
||||
|
@ -92,6 +99,7 @@ class FederatedShareProvider implements IShareProvider {
|
|||
$this->l = $l10n;
|
||||
$this->logger = $logger;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -601,4 +609,24 @@ class FederatedShareProvider implements IShareProvider {
|
|||
// We don't handle groups here
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if users from other ownCloud instances are allowed to mount public links share by this instance
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOutgoingServer2serverShareEnabled() {
|
||||
$result = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
|
||||
return ($result === 'yes') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if users are allowed to mount public links from other ownClouds
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isIncomingServer2serverShareEnabled() {
|
||||
$result = $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
|
||||
return ($result === 'yes') ? true : false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
||||
|
||||
\OC_Util::checkAdminUser();
|
||||
|
||||
\OCP\Util::addScript('files_sharing', 'settings-admin');
|
||||
$app = new Application('federatedfilesharing');
|
||||
$federatedShareProvider = $app->getFederatedShareProvider();
|
||||
|
||||
$tmpl = new OCP\Template('files_sharing', 'settings-admin');
|
||||
$tmpl->assign('outgoingServer2serverShareEnabled', OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled());
|
||||
$tmpl->assign('incomingServer2serverShareEnabled', OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled());
|
||||
$tmpl = new OCP\Template('federatedfilesharing', 'settings-admin');
|
||||
$tmpl->assign('outgoingServer2serverShareEnabled', $federatedShareProvider->isOutgoingServer2serverShareEnabled());
|
||||
$tmpl->assign('incomingServer2serverShareEnabled', $federatedShareProvider->isIncomingServer2serverShareEnabled());
|
||||
|
||||
return $tmpl->fetchPage();
|
|
@ -21,9 +21,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
||||
|
||||
\OC_Util::checkLoggedIn();
|
||||
|
||||
$l = \OC::$server->getL10N('files_sharing');
|
||||
$l = \OC::$server->getL10N('federatedfilesharing');
|
||||
|
||||
$app = new Application('federatedfilesharing');
|
||||
$federatedShareProvider = $app->getFederatedShareProvider();
|
||||
|
||||
$isIE8 = false;
|
||||
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
|
||||
|
@ -35,8 +40,8 @@ $cloudID = \OC::$server->getUserSession()->getUser()->getCloudId();
|
|||
$url = 'https://owncloud.org/federation#' . $cloudID;
|
||||
$ownCloudLogoPath = \OC::$server->getURLGenerator()->imagePath('core', 'logo-icon.svg');
|
||||
|
||||
$tmpl = new OCP\Template('files_sharing', 'settings-personal');
|
||||
$tmpl->assign('outgoingServer2serverShareEnabled', \OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled());
|
||||
$tmpl = new OCP\Template('federatedfilesharing', 'settings-personal');
|
||||
$tmpl->assign('outgoingServer2serverShareEnabled', $federatedShareProvider->isOutgoingServer2serverShareEnabled());
|
||||
$tmpl->assign('message_with_URL', $l->t('Share with me through my #ownCloud Federated Cloud ID, see %s', [$url]));
|
||||
$tmpl->assign('message_without_URL', $l->t('Share with me through my #ownCloud Federated Cloud ID', [$cloudID]));
|
||||
$tmpl->assign('owncloud_logo_path', $ownCloudLogoPath);
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
/** @var OC_L10N $l */
|
||||
/** @var array $_ */
|
||||
script('federatedfilesharing', 'settings-admin');
|
||||
?>
|
||||
|
||||
<div id="fileSharingSettings">
|
||||
<h3><?php p($l->t('Federated Cloud Sharing'));?></h3>
|
||||
<a target="_blank" rel="noreferrer" class="icon-info svg"
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
/** @var OC_L10N $l */
|
||||
/** @var array $_ */
|
||||
script('files_sharing', 'settings-personal');
|
||||
style('files_sharing', 'settings-personal');
|
||||
script('federatedfilesharing', 'settings-personal');
|
||||
style('federatedfilesharing', 'settings-personal');
|
||||
if ($_['showShareIT']) {
|
||||
script('files_sharing', '3rdparty/gs-share/gs-share');
|
||||
style('files_sharing', '3rdparty/gs-share/style');
|
||||
script('federatedfilesharing', '3rdparty/gs-share/gs-share');
|
||||
style('federatedfilesharing', '3rdparty/gs-share/style');
|
||||
}
|
||||
?>
|
||||
|
|
@ -26,6 +26,7 @@ use OCA\FederatedFileSharing\FederatedShareProvider;
|
|||
use OCA\FederatedFileSharing\Notifications;
|
||||
use OCA\FederatedFileSharing\TokenHandler;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
|
@ -54,6 +55,8 @@ class FederatedShareProviderTest extends TestCase {
|
|||
protected $logger;
|
||||
/** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $rootFolder;
|
||||
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $config;
|
||||
|
||||
/** @var IManager */
|
||||
protected $shareManager;
|
||||
|
@ -78,6 +81,7 @@ class FederatedShareProviderTest extends TestCase {
|
|||
}));
|
||||
$this->logger = $this->getMock('OCP\ILogger');
|
||||
$this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
|
||||
$this->config = $this->getMock('OCP\IConfig');
|
||||
$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l);
|
||||
|
||||
$this->provider = new FederatedShareProvider(
|
||||
|
@ -87,7 +91,8 @@ class FederatedShareProviderTest extends TestCase {
|
|||
$this->tokenHandler,
|
||||
$this->l,
|
||||
$this->logger,
|
||||
$this->rootFolder
|
||||
$this->rootFolder,
|
||||
$this->config
|
||||
);
|
||||
|
||||
$this->shareManager = \OC::$server->getShareManager();
|
||||
|
@ -510,4 +515,43 @@ class FederatedShareProviderTest extends TestCase {
|
|||
|
||||
$this->assertCount($rowDeleted ? 0 : 1, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestFederatedSharingSettings
|
||||
*
|
||||
* @param string $isEnabled
|
||||
* @param bool $expected
|
||||
*/
|
||||
public function testIsOutgoingServer2serverShareEnabled($isEnabled, $expected) {
|
||||
$this->config->expects($this->once())->method('getAppValue')
|
||||
->with('files_sharing', 'outgoing_server2server_share_enabled', 'yes')
|
||||
->willReturn($isEnabled);
|
||||
|
||||
$this->assertSame($expected,
|
||||
$this->provider->isOutgoingServer2serverShareEnabled()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestFederatedSharingSettings
|
||||
*
|
||||
* @param string $isEnabled
|
||||
* @param bool $expected
|
||||
*/
|
||||
public function testIsIncomingServer2serverShareEnabled($isEnabled, $expected) {
|
||||
$this->config->expects($this->once())->method('getAppValue')
|
||||
->with('files_sharing', 'incoming_server2server_share_enabled', 'yes')
|
||||
->willReturn($isEnabled);
|
||||
|
||||
$this->assertSame($expected,
|
||||
$this->provider->isIncomingServer2serverShareEnabled()
|
||||
);
|
||||
}
|
||||
|
||||
public function dataTestFederatedSharingSettings() {
|
||||
return [
|
||||
['yes', true],
|
||||
['no', false]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,11 @@ OCP\JSON::checkAppEnabled('files_sharing');
|
|||
|
||||
$l = \OC::$server->getL10N('files_sharing');
|
||||
|
||||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
|
||||
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
|
||||
|
||||
// check if server admin allows to mount public links from other servers
|
||||
if (OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled() === false) {
|
||||
if ($federatedShareProvider->isIncomingServer2serverShareEnabled() === false) {
|
||||
\OCP\JSON::error(array('data' => array('message' => $l->t('Server to server sharing is not enabled on this server'))));
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,10 @@ if (!isset($_GET['t'])) {
|
|||
exit;
|
||||
}
|
||||
|
||||
if (OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled() === false) {
|
||||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
|
||||
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
|
||||
|
||||
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false) {
|
||||
\OC_Response::setStatus(404); // 404 not found
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -26,11 +26,25 @@
|
|||
namespace OCA\Files_Sharing\API;
|
||||
|
||||
use OCA\FederatedFileSharing\DiscoveryManager;
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCA\Files_Sharing\Activity;
|
||||
use OCP\Files\NotFoundException;
|
||||
|
||||
class Server2Server {
|
||||
|
||||
/** @var FederatedShareProvider */
|
||||
private $federatedShareProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Server2Server constructor.
|
||||
*
|
||||
* @param FederatedShareProvider $federatedShareProvider
|
||||
*/
|
||||
public function __construct(FederatedShareProvider $federatedShareProvider) {
|
||||
$this->federatedShareProvider = $federatedShareProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new share
|
||||
*
|
||||
|
@ -300,9 +314,9 @@ class Server2Server {
|
|||
$result = \OCP\App::isEnabled('files_sharing');
|
||||
|
||||
if ($incoming) {
|
||||
$result = $result && \OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled();
|
||||
$result = $result && $this->federatedShareProvider->isIncomingServer2serverShareEnabled();
|
||||
} else {
|
||||
$result = $result && \OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled();
|
||||
$result = $result && $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
@ -44,9 +44,6 @@ $l = \OC::$server->getL10N('files_sharing');
|
|||
$application = new Application();
|
||||
$application->registerMountProviders();
|
||||
|
||||
\OCP\App::registerAdmin('files_sharing', 'settings-admin');
|
||||
\OCP\App::registerPersonal('files_sharing', 'settings-personal');
|
||||
|
||||
\OCA\Files_Sharing\Helper::registerHooks();
|
||||
|
||||
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
|
||||
|
|
|
@ -45,6 +45,7 @@ class Application extends App {
|
|||
* Controllers
|
||||
*/
|
||||
$container->registerService('ShareController', function (SimpleContainer $c) use ($server) {
|
||||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
|
||||
return new ShareController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
|
@ -56,7 +57,8 @@ class Application extends App {
|
|||
$server->getShareManager(),
|
||||
$server->getSession(),
|
||||
$server->getPreviewManager(),
|
||||
$server->getRootFolder()
|
||||
$server->getRootFolder(),
|
||||
$federatedSharingApp->getFederatedShareProvider()
|
||||
);
|
||||
});
|
||||
$container->registerService('ExternalSharesController', function (SimpleContainer $c) {
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace OCA\Files_Sharing\Controllers;
|
|||
use OC;
|
||||
use OC_Files;
|
||||
use OC_Util;
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCP;
|
||||
use OCP\Template;
|
||||
use OCP\Share;
|
||||
|
@ -79,6 +80,8 @@ class ShareController extends Controller {
|
|||
protected $previewManager;
|
||||
/** @var IRootFolder */
|
||||
protected $rootFolder;
|
||||
/** @var FederatedShareProvider */
|
||||
protected $federatedShareProvider;
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
|
@ -92,6 +95,7 @@ class ShareController extends Controller {
|
|||
* @param ISession $session
|
||||
* @param IPreview $previewManager
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param FederatedShareProvider $federatedShareProvider
|
||||
*/
|
||||
public function __construct($appName,
|
||||
IRequest $request,
|
||||
|
@ -103,7 +107,8 @@ class ShareController extends Controller {
|
|||
\OCP\Share\IManager $shareManager,
|
||||
ISession $session,
|
||||
IPreview $previewManager,
|
||||
IRootFolder $rootFolder) {
|
||||
IRootFolder $rootFolder,
|
||||
FederatedShareProvider $federatedShareProvider) {
|
||||
parent::__construct($appName, $request);
|
||||
|
||||
$this->config = $config;
|
||||
|
@ -115,6 +120,7 @@ class ShareController extends Controller {
|
|||
$this->session = $session;
|
||||
$this->previewManager = $previewManager;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->federatedShareProvider = $federatedShareProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,7 +306,7 @@ class ShareController extends Controller {
|
|||
$shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($share->getNode()->getMimetype());
|
||||
$shareTmpl['dirToken'] = $token;
|
||||
$shareTmpl['sharingToken'] = $token;
|
||||
$shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
|
||||
$shareTmpl['server2serversharing'] = $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
|
||||
$shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
|
||||
$shareTmpl['dir'] = '';
|
||||
$shareTmpl['nonHumanFileSize'] = $share->getNode()->getSize();
|
||||
|
|
|
@ -279,26 +279,6 @@ class Helper {
|
|||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* allow users from other ownCloud instances to mount public links share by this instance
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOutgoingServer2serverShareEnabled() {
|
||||
$appConfig = \OC::$server->getAppConfig();
|
||||
$result = $appConfig->getValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
|
||||
return ($result === 'yes') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* allow user to mount public links from onther ownClouds
|
||||
* @return bool
|
||||
*/
|
||||
public static function isIncomingServer2serverShareEnabled() {
|
||||
$appConfig = \OC::$server->getAppConfig();
|
||||
$result = $appConfig->getValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
|
||||
return ($result === 'yes') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get default share folder
|
||||
*
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
|
||||
/**
|
||||
* @author Andreas Fischer <bantu@owncloud.com>
|
||||
* @author Bart Visscher <bartv@thisnet.nl>
|
||||
|
@ -40,6 +42,18 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
|||
|
||||
private $path;
|
||||
|
||||
/** @var FederatedShareProvider */
|
||||
private $federatedShareProvider;
|
||||
|
||||
public function __construct(FederatedShareProvider $federatedShareProvider = null) {
|
||||
if ($federatedShareProvider) {
|
||||
$this->federatedShareProvider = $federatedShareProvider;
|
||||
} else {
|
||||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
|
||||
$this->federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
|
||||
}
|
||||
}
|
||||
|
||||
public function isValidSource($itemSource, $uidOwner) {
|
||||
try {
|
||||
$path = \OC\Files\Filesystem::getPath($itemSource);
|
||||
|
@ -173,7 +187,7 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
|
|||
*/
|
||||
public function isShareTypeAllowed($shareType) {
|
||||
if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
|
||||
return \OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled();
|
||||
return $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
namespace OCA\Files_Sharing\Controllers;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
|
@ -66,6 +67,8 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
private $shareManager;
|
||||
/** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userManager;
|
||||
/** @var FederatedShareProvider | \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $federatedShareProvider;
|
||||
|
||||
protected function setUp() {
|
||||
$this->appName = 'files_sharing';
|
||||
|
@ -76,6 +79,12 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
$this->previewManager = $this->getMock('\OCP\IPreview');
|
||||
$this->config = $this->getMock('\OCP\IConfig');
|
||||
$this->userManager = $this->getMock('\OCP\IUserManager');
|
||||
$this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->federatedShareProvider->expects($this->any())
|
||||
->method('isOutgoingServer2serverShareEnabled')->willReturn(true);
|
||||
$this->federatedShareProvider->expects($this->any())
|
||||
->method('isIncomingServer2serverShareEnabled')->willReturn(true);
|
||||
|
||||
$this->shareController = new \OCA\Files_Sharing\Controllers\ShareController(
|
||||
$this->appName,
|
||||
|
@ -88,7 +97,8 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
$this->shareManager,
|
||||
$this->session,
|
||||
$this->previewManager,
|
||||
$this->getMock('\OCP\Files\IRootFolder')
|
||||
$this->getMock('\OCP\Files\IRootFolder'),
|
||||
$this->federatedShareProvider
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
|
|||
*/
|
||||
private $s2s;
|
||||
|
||||
/** @var \OCA\FederatedFileSharing\FederatedShareProvider | PHPUnit_Framework_MockObject_MockObject */
|
||||
private $federatedShareProvider;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
@ -57,10 +60,16 @@ class Test_Files_Sharing_S2S_OCS_API extends TestCase {
|
|||
->setConstructorArgs([$config, $clientService])
|
||||
->getMock();
|
||||
$httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true));
|
||||
$this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->federatedShareProvider->expects($this->any())
|
||||
->method('isOutgoingServer2serverShareEnabled')->willReturn(true);
|
||||
$this->federatedShareProvider->expects($this->any())
|
||||
->method('isIncomingServer2serverShareEnabled')->willReturn(true);
|
||||
|
||||
$this->registerHttpHelper($httpHelperMock);
|
||||
|
||||
$this->s2s = new \OCA\Files_Sharing\API\Server2Server();
|
||||
$this->s2s = new \OCA\Files_Sharing\API\Server2Server($this->federatedShareProvider);
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
}
|
||||
|
|
|
@ -114,7 +114,8 @@ class ProviderFactory implements IProviderFactory {
|
|||
$tokenHandler,
|
||||
$l,
|
||||
$this->serverContainer->getLogger(),
|
||||
$this->serverContainer->getLazyRootFolder()
|
||||
$this->serverContainer->getLazyRootFolder(),
|
||||
$this->serverContainer->getConfig()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,8 @@ API::register(
|
|||
|
||||
// Server-to-Server Sharing
|
||||
if (\OC::$server->getAppManager()->isEnabledForUser('files_sharing')) {
|
||||
$s2s = new \OCA\Files_Sharing\API\Server2Server();
|
||||
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
|
||||
$s2s = new \OCA\Files_Sharing\API\Server2Server($federatedSharingApp->getFederatedShareProvider());
|
||||
API::register('post',
|
||||
'/cloud/shares',
|
||||
array($s2s, 'createShare'),
|
||||
|
|