Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2019-02-22 18:36:25 +0300
committerRobin Appelman <robin@icewind.nl>2019-02-25 18:06:09 +0300
commitdb750898ee3cb165218f4428265ab9dc258c93c2 (patch)
tree5a9e6472b98992b35b62ca7d5d1b1273f8466f48 /lib
parentd7538f9a61a2af288d82fc257524aee5c2f86769 (diff)
allow group backends to mark that a group should now be shown in search dialogs
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Collaboration/Collaborators/GroupPlugin.php4
-rw-r--r--lib/private/Group/Group.php11
-rw-r--r--lib/public/Group/Backend/IHideFromCollaborationBackend.php38
-rw-r--r--lib/public/IGroup.php6
4 files changed, 59 insertions, 0 deletions
diff --git a/lib/private/Collaboration/Collaborators/GroupPlugin.php b/lib/private/Collaboration/Collaborators/GroupPlugin.php
index 7eee042076e..b1e331132be 100644
--- a/lib/private/Collaboration/Collaborators/GroupPlugin.php
+++ b/lib/private/Collaboration/Collaborators/GroupPlugin.php
@@ -73,6 +73,10 @@ class GroupPlugin implements ISearchPlugin {
$lowerSearch = strtolower($search);
foreach ($groups as $group) {
+ if ($group->hideFromCollaboration()) {
+ continue;
+ }
+
// FIXME: use a more efficient approach
$gid = $group->getGID();
if (!in_array($gid, $groupIds)) {
diff --git a/lib/private/Group/Group.php b/lib/private/Group/Group.php
index 0d54cf8e35a..df8de7af5d5 100644
--- a/lib/private/Group/Group.php
+++ b/lib/private/Group/Group.php
@@ -30,6 +30,7 @@
namespace OC\Group;
+use OCP\Group\Backend\IHideFromCollaborationBackend;
use OCP\GroupInterface;
use OCP\IGroup;
use OCP\IUser;
@@ -350,4 +351,14 @@ class Group implements IGroup {
}
return false;
}
+
+ /**
+ * @return bool
+ * @since 16.0.0
+ */
+ public function hideFromCollaboration(): bool {
+ return array_reduce($this->backends, function(bool $hide, GroupInterface $backend) {
+ return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
+ }, false);
+ }
}
diff --git a/lib/public/Group/Backend/IHideFromCollaborationBackend.php b/lib/public/Group/Backend/IHideFromCollaborationBackend.php
new file mode 100644
index 00000000000..81afbc3d568
--- /dev/null
+++ b/lib/public/Group/Backend/IHideFromCollaborationBackend.php
@@ -0,0 +1,38 @@
+<?php declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
+ *
+ * @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 OCP\Group\Backend;
+
+/**
+ * @since 16.0.0
+ *
+ * Allow the backend to mark groups to be excluded from being shown in search dialogs
+ */
+interface IHideFromCollaborationBackend {
+ /**
+ * Check if a group should be hidden from search dialogs
+ *
+ * @param string $groupId
+ * @return bool
+ * @since 16.0.0
+ */
+ public function hideGroup(string $groupId): bool;
+}
diff --git a/lib/public/IGroup.php b/lib/public/IGroup.php
index 8fa87e35ce3..48fa84df393 100644
--- a/lib/public/IGroup.php
+++ b/lib/public/IGroup.php
@@ -138,4 +138,10 @@ interface IGroup {
* @since 14.0.0
*/
public function canAddUser();
+
+ /**
+ * @return bool
+ * @since 16.0.0
+ */
+ public function hideFromCollaboration(): bool;
}