diff options
Diffstat (limited to 'apps/federatedfilesharing/lib')
-rw-r--r-- | apps/federatedfilesharing/lib/AppInfo/Application.php | 5 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/FederatedShareProvider.php | 22 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/Settings/Admin.php | 15 |
3 files changed, 39 insertions, 3 deletions
diff --git a/apps/federatedfilesharing/lib/AppInfo/Application.php b/apps/federatedfilesharing/lib/AppInfo/Application.php index 9d8464e37d5..346d3c4e292 100644 --- a/apps/federatedfilesharing/lib/AppInfo/Application.php +++ b/apps/federatedfilesharing/lib/AppInfo/Application.php @@ -30,6 +30,7 @@ use OCA\FederatedFileSharing\Controller\RequestHandlerController; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\Notifications; use OCP\AppFramework\App; +use OCP\GlobalScale\IConfig; class Application extends App { @@ -91,6 +92,7 @@ class Application extends App { * initialize federated share provider */ protected function initFederatedShareProvider() { + $c = $this->getContainer(); $addressHandler = new \OCA\FederatedFileSharing\AddressHandler( \OC::$server->getURLGenerator(), \OC::$server->getL10N('federatedfilesharing'), @@ -116,7 +118,8 @@ class Application extends App { \OC::$server->getLazyRootFolder(), \OC::$server->getConfig(), \OC::$server->getUserManager(), - \OC::$server->getCloudIdManager() + \OC::$server->getCloudIdManager(), + $c->query(IConfig::class) ); } diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 34e02391e05..60a54c6ca3c 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -85,6 +85,9 @@ class FederatedShareProvider implements IShareProvider { /** @var ICloudIdManager */ private $cloudIdManager; + /** @var \OCP\GlobalScale\IConfig */ + private $gsConfig; + /** * DefaultShareProvider constructor. * @@ -98,6 +101,7 @@ class FederatedShareProvider implements IShareProvider { * @param IConfig $config * @param IUserManager $userManager * @param ICloudIdManager $cloudIdManager + * @param \OCP\GlobalScale\IConfig $globalScaleConfig */ public function __construct( IDBConnection $connection, @@ -109,7 +113,8 @@ class FederatedShareProvider implements IShareProvider { IRootFolder $rootFolder, IConfig $config, IUserManager $userManager, - ICloudIdManager $cloudIdManager + ICloudIdManager $cloudIdManager, + \OCP\GlobalScale\IConfig $globalScaleConfig ) { $this->dbConnection = $connection; $this->addressHandler = $addressHandler; @@ -121,6 +126,7 @@ class FederatedShareProvider implements IShareProvider { $this->config = $config; $this->userManager = $userManager; $this->cloudIdManager = $cloudIdManager; + $this->gsConfig = $globalScaleConfig; } /** @@ -941,6 +947,9 @@ class FederatedShareProvider implements IShareProvider { * @return bool */ public function isOutgoingServer2serverShareEnabled() { + if ($this->gsConfig->onlyInternalFederation()) { + return false; + } $result = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes'); return ($result === 'yes'); } @@ -951,6 +960,9 @@ class FederatedShareProvider implements IShareProvider { * @return bool */ public function isIncomingServer2serverShareEnabled() { + if ($this->gsConfig->onlyInternalFederation()) { + return false; + } $result = $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes'); return ($result === 'yes'); } @@ -961,6 +973,10 @@ class FederatedShareProvider implements IShareProvider { * @return bool */ public function isLookupServerQueriesEnabled() { + // in a global scale setup we should always query the lookup server + if ($this->gsConfig->isGlobalScaleEnabled()) { + return true; + } $result = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no'); return ($result === 'yes'); } @@ -972,6 +988,10 @@ class FederatedShareProvider implements IShareProvider { * @return bool */ public function isLookupServerUploadEnabled() { + // in a global scale setup the admin is responsible to keep the lookup server up-to-date + if ($this->gsConfig->isGlobalScaleEnabled()) { + return false; + } $result = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); return ($result === 'yes'); } diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php index baac4b1086f..47470fd5841 100644 --- a/apps/federatedfilesharing/lib/Settings/Admin.php +++ b/apps/federatedfilesharing/lib/Settings/Admin.php @@ -25,6 +25,7 @@ namespace OCA\FederatedFileSharing\Settings; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\AppFramework\Http\TemplateResponse; +use OCP\GlobalScale\IConfig; use OCP\Settings\ISettings; class Admin implements ISettings { @@ -32,15 +33,27 @@ class Admin implements ISettings { /** @var FederatedShareProvider */ private $fedShareProvider; - public function __construct(FederatedShareProvider $fedShareProvider) { + /** @var IConfig */ + private $gsConfig; + + /** + * Admin constructor. + * + * @param FederatedShareProvider $fedShareProvider + * @param IConfig $globalScaleConfig + */ + public function __construct(FederatedShareProvider $fedShareProvider, IConfig $globalScaleConfig) { $this->fedShareProvider = $fedShareProvider; + $this->gsConfig = $globalScaleConfig; } /** * @return TemplateResponse */ public function getForm() { + $parameters = [ + 'internalOnly' => $this->gsConfig->onlyInternalFederation(), 'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(), 'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(), 'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(), |