aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-06-25 11:40:16 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-11 10:11:41 +0200
commitc8631d607ef827f0eb29312faf7b2b808e1a8e7d (patch)
tree1ef1aec833e6f6ada8c77c3388a5ff059175b039
parenta22bc0e78758a86000b1023c93e554ebca696493 (diff)
downloadnextcloud-server-c8631d607ef827f0eb29312faf7b2b808e1a8e7d.tar.gz
nextcloud-server-c8631d607ef827f0eb29312faf7b2b808e1a8e7d.zip
add setting to enable/disable federated group sharing
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php45
-rw-r--r--apps/federatedfilesharing/lib/Settings/Admin.php3
-rw-r--r--apps/federatedfilesharing/templates/settings-admin.php17
3 files changed, 63 insertions, 2 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index f81b826f12c..d32560c4ffd 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -30,6 +30,7 @@
namespace OCA\FederatedFileSharing;
use OC\Share20\Share;
+use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Folder;
@@ -92,6 +93,9 @@ class FederatedShareProvider implements IShareProvider {
/** @var \OCP\GlobalScale\IConfig */
private $gsConfig;
+ /** @var ICloudFederationProviderManager */
+ private $cloudFederationProviderManager;
+
/**
* DefaultShareProvider constructor.
*
@@ -106,6 +110,7 @@ class FederatedShareProvider implements IShareProvider {
* @param IUserManager $userManager
* @param ICloudIdManager $cloudIdManager
* @param \OCP\GlobalScale\IConfig $globalScaleConfig
+ * @param ICloudFederationProviderManager $cloudFederationProviderManager
*/
public function __construct(
IDBConnection $connection,
@@ -118,7 +123,8 @@ class FederatedShareProvider implements IShareProvider {
IConfig $config,
IUserManager $userManager,
ICloudIdManager $cloudIdManager,
- \OCP\GlobalScale\IConfig $globalScaleConfig
+ \OCP\GlobalScale\IConfig $globalScaleConfig,
+ ICloudFederationProviderManager $cloudFederationProviderManager
) {
$this->dbConnection = $connection;
$this->addressHandler = $addressHandler;
@@ -131,6 +137,7 @@ class FederatedShareProvider implements IShareProvider {
$this->userManager = $userManager;
$this->cloudIdManager = $cloudIdManager;
$this->gsConfig = $globalScaleConfig;
+ $this->cloudFederationProviderManager = $cloudFederationProviderManager;
}
/**
@@ -967,6 +974,42 @@ class FederatedShareProvider implements IShareProvider {
return ($result === 'yes');
}
+
+ /**
+ * check if users from other Nextcloud instances are allowed to send federated group shares
+ *
+ * @return bool
+ */
+ public function isOutgoingServer2serverGroupShareEnabled() {
+ if ($this->gsConfig->onlyInternalFederation()) {
+ return false;
+ }
+ $result = $this->config->getAppValue('files_sharing', 'outgoing_server2server_group_share_enabled', 'no');
+ return ($result === 'yes');
+ }
+
+ /**
+ * check if users are allowed to receive federated group shares
+ *
+ * @return bool
+ */
+ public function isIncomingServer2serverGroupShareEnabled() {
+ if ($this->gsConfig->onlyInternalFederation()) {
+ return false;
+ }
+ $result = $this->config->getAppValue('files_sharing', 'incoming_server2server_group_share_enabled', 'no');
+ return ($result === 'yes');
+ }
+
+ /**
+ * check if federated group sharing is supported, therefore the OCM API need to be enabled
+ *
+ * @return bool
+ */
+ public function isFederatedGroupSharingSupported() {
+ return $this->cloudFederationProviderManager->isReady();
+ }
+
/**
* Check if querying sharees on the lookup server is enabled
*
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index cbeaa167fff..aea7957a49f 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -58,6 +58,9 @@ class Admin implements ISettings {
'internalOnly' => $this->gsConfig->onlyInternalFederation(),
'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(),
'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(),
+ 'federatedGroupSharingSupported' => $this->fedShareProvider->isFederatedGroupSharingSupported(),
+ 'outgoingServer2serverGroupShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled(),
+ 'incomingServer2serverGroupShareEnabled' => $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled(),
'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(),
'lookupServerUploadEnabled' => $this->fedShareProvider->isLookupServerUploadEnabled(),
];
diff --git a/apps/federatedfilesharing/templates/settings-admin.php b/apps/federatedfilesharing/templates/settings-admin.php
index 187d75f21ac..1b9b88dc03e 100644
--- a/apps/federatedfilesharing/templates/settings-admin.php
+++ b/apps/federatedfilesharing/templates/settings-admin.php
@@ -23,7 +23,6 @@ script('federatedfilesharing', 'settings-admin');
<?php p($l->t('Allow users on this server to send shares to other servers'));?>
</label>
</p>
-
<p>
<input type="checkbox" name="incoming_server2server_share_enabled" id="incomingServer2serverShareEnabled" class="checkbox"
value="1" <?php if ($_['incomingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> />
@@ -31,6 +30,22 @@ script('federatedfilesharing', 'settings-admin');
<?php p($l->t('Allow users on this server to receive shares from other servers'));?>
</label><br/>
</p>
+ <?php if($_['federatedGroupSharingSupported']): ?>
+ <p>
+ <input type="checkbox" name="outgoing_server2server_group_share_enabled" id="outgoingServer2serverGroupShareEnabled" class="checkbox"
+ value="1" <?php if ($_['outgoingServer2serverGroupShareEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="outgoingServer2serverGroupShareEnabled">
+ <?php p($l->t('Allow users on this server to send shares to groups on other servers'));?>
+ </label>
+ </p>
+ <p>
+ <input type="checkbox" name="incoming_server2server_group_share_enabled" id="incomingServer2serverGroupShareEnabled" class="checkbox"
+ value="1" <?php if ($_['incomingServer2serverGroupShareEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="incomingServer2serverGroupShareEnabled">
+ <?php p($l->t('Allow users on this server to receive group shares from other servers'));?>
+ </label><br/>
+ </p>
+ <?php endif; ?>
<p>
<input type="checkbox" name="lookupServerEnabled" id="lookupServerEnabled" class="checkbox"
value="1" <?php if ($_['lookupServerEnabled']) print_unescaped('checked="checked"'); ?> />