diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-06-16 11:31:04 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-06-16 11:31:04 +0200 |
commit | 497fe93b6c0a7de212e69ec8a343867cb4904dca (patch) | |
tree | 07a4f08a520ee95bc69f3311cef90342195d36d9 | |
parent | 171f86ca2e71918809930e823062d93c03833921 (diff) | |
download | nextcloud-server-497fe93b6c0a7de212e69ec8a343867cb4904dca.tar.gz nextcloud-server-497fe93b6c0a7de212e69ec8a343867cb4904dca.zip |
Do not return backends but add a method to check for one
-rw-r--r-- | lib/private/group/manager.php | 17 | ||||
-rw-r--r-- | lib/public/igroupmanager.php | 7 | ||||
-rw-r--r-- | settings/users.php | 10 |
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; } } |