From 3c1380b093fcfe5d94927529ccc726b4ed56e99f Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 14 Aug 2012 14:22:05 +0200 Subject: [PATCH] LDAP: adjust getGroups to updated interface --- apps/user_ldap/group_ldap.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/user_ldap/group_ldap.php b/apps/user_ldap/group_ldap.php index aff25593ef..d0d1ae3035 100644 --- a/apps/user_ldap/group_ldap.php +++ b/apps/user_ldap/group_ldap.php @@ -185,18 +185,27 @@ class GROUP_LDAP extends lib\Access implements \OCP\GroupInterface { * * Returns a list with all groups */ - public function getGroups() { + public function getGroups($search = '', $limit = -1, $offset = 0) { if(!$this->enabled) { return array(); } - if($this->connection->isCached('getGroups')) { - return $this->connection->getFromCache('getGroups'); - } - $ldap_groups = $this->fetchListOfGroups($this->connection->ldapGroupFilter, array($this->connection->ldapGroupDisplayName, 'dn')); - $ldap_groups = $this->ownCloudGroupNames($ldap_groups); - $this->connection->writeToCache('getGroups', $ldap_groups); - return $ldap_groups; + if($this->connection->isCached('getGroups')) { + $ldap_groups = $this->connection->getFromCache('getGroups'); + } else { + $ldap_groups = $this->fetchListOfGroups($this->connection->ldapGroupFilter, array($this->connection->ldapGroupDisplayName, 'dn')); + $ldap_groups = $this->ownCloudGroupNames($ldap_groups); + $this->connection->writeToCache('getGroups', $ldap_groups); + } + $this->groupSearch = $search; + if(!empty($this->groupSearch)) { + $ldap_groups = array_filter($ldap_groups, array($this, 'groupMatchesFilter')); + } + return array_slice($ldap_groups, $offset, $limit); + } + + public function groupMatchesFilter($group) { + return (strripos($group, $this->groupSearch) !== false); } /**