summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-07-02 11:29:03 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-11 10:11:47 +0200
commit2abc70563221457843346e452f916bf2b49a00ad (patch)
treeaf698d867dfeac7f74625963616e6f4f3aefa823 /lib/private
parent1d5a9c3f979b23bac98243ba2245a21bdff722c8 (diff)
downloadnextcloud-server-2abc70563221457843346e452f916bf2b49a00ad.tar.gz
nextcloud-server-2abc70563221457843346e452f916bf2b49a00ad.zip
start to get fed group shares into the share dialog
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php78
-rw-r--r--lib/private/Server.php2
2 files changed, 80 insertions, 0 deletions
diff --git a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php
new file mode 100644
index 00000000000..c48a1fbae20
--- /dev/null
+++ b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Collaboration\Collaborators;
+
+
+use OCP\Collaboration\Collaborators\ISearchPlugin;
+use OCP\Collaboration\Collaborators\ISearchResult;
+use OCP\Collaboration\Collaborators\SearchResultType;
+use OCP\Contacts\IManager;
+use OCP\Federation\ICloudFederationProviderManager;
+use OCP\Federation\ICloudIdManager;
+use OCP\IConfig;
+use OCP\Share;
+
+class RemoteGroupPlugin implements ISearchPlugin {
+ protected $shareeEnumeration;
+
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+ /** @var IConfig */
+ private $config;
+ /** @var bool */
+ private $enabled = false;
+
+ public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager, ICloudIdManager $cloudIdManager) {
+ try {
+ $fileSharingProvider = $cloudFederationProviderManager->getCloudFederationProvider('file');
+ $supportedShareTypes = $fileSharingProvider->getSupportedShareTypes();
+ if (in_array('group', $supportedShareTypes)) {
+ $this->enabled = true;
+ }
+ } catch (\Exception $e) {
+ // do nothing, just don't enable federated group shares
+ }
+ $this->cloudIdManager = $cloudIdManager;
+ }
+
+ public function search($search, $limit, $offset, ISearchResult $searchResult) {
+ $result = ['wide' => [], 'exact' => []];
+ $resultType = new SearchResultType('remote_groups');
+
+ if ($this->enabled && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
+ $result['exact'][] = [
+ 'label' => $search,
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_REMOTE_GROUP,
+ 'shareWith' => $search,
+ ],
+ ];
+ }
+
+ $searchResult->addResultSet($resultType, $result['wide'], $result['exact']);
+
+ return true;
+ }
+
+}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 90e9e81c105..c9f8001631e 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -60,6 +60,7 @@ use OC\Authentication\LoginCredentials\Store;
use OC\Authentication\Token\IProvider;
use OC\Collaboration\Collaborators\GroupPlugin;
use OC\Collaboration\Collaborators\MailPlugin;
+use OC\Collaboration\Collaborators\RemoteGroupPlugin;
use OC\Collaboration\Collaborators\RemotePlugin;
use OC\Collaboration\Collaborators\UserPlugin;
use OC\Command\CronBus;
@@ -1066,6 +1067,7 @@ class Server extends ServerContainer implements IServerContainer {
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
+ $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
return $instance;
});