Do not return backends but add a method to check for one
This commit is contained in:
parent
171f86ca2e
commit
497fe93b6c
3 changed files with 23 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue