summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/group/manager.php17
-rw-r--r--lib/public/igroupmanager.php7
-rw-r--r--settings/users.php10
3 files changed, 23 insertions, 11 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 6399f16f9c8..70263fc2afa 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -98,10 +98,21 @@ class Manager extends PublicEmitter implements IGroupManager {
}
/**
- * @return \OC_Group_Backend[] Get registered backends
+ * Checks whether a given backend is used
+ *
+ * @param string $backendClass Full classname including complete namespace
+ * @return bool
*/
- public function getBackends() {
- return $this->backends;
+ public function isBackendUsed($backendClass) {
+ $backendClass = strtolower(ltrim($backendClass, '\\'));
+
+ foreach ($this->backends as $backend) {
+ if (strtolower(get_class($backend)) === $backendClass) {
+ return true;
+ }
+ }
+
+ return false;
}
/**
diff --git a/lib/public/igroupmanager.php b/lib/public/igroupmanager.php
index 4e984e58d89..ec4b03c5d18 100644
--- a/lib/public/igroupmanager.php
+++ b/lib/public/igroupmanager.php
@@ -41,10 +41,13 @@ namespace OCP;
*/
interface IGroupManager {
/**
- * @return \OC_Group_Backend[] Get registered backends
+ * Checks whether a given backend is used
+ *
+ * @param string $backendClass Full classname including complete namespace
+ * @return bool
* @since 8.1.0
*/
- public function getBackends();
+ public function isBackendUsed($backendClass);
/**
* @param \OCP\UserInterface $backend
diff --git a/settings/users.php b/settings/users.php
index 5da6902b8fa..c438e5fbfd0 100644
--- a/settings/users.php
+++ b/settings/users.php
@@ -41,12 +41,10 @@ $groupManager = \OC_Group::getManager();
$sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
if (class_exists('\OCA\user_ldap\GROUP_LDAP')) {
- $backends = $groupManager->getBackends();
- foreach ($backends as $backend) {
- if ($backend instanceof \OCA\user_ldap\GROUP_LDAP) {
- // LDAP user count can be slow, so we sort by gorup name here
- $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
- }
+ $isLDAPUsed = $groupManager->isBackendUsed('\OCA\user_ldap\GROUP_LDAP');
+ if ($isLDAPUsed) {
+ // LDAP user count can be slow, so we sort by group name here
+ $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
}
}