diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-30 20:20:46 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-07-30 20:20:46 -0400 |
commit | 2f1a990cadc5202dd20c3ec87e886685f6733595 (patch) | |
tree | 4e44165d0d87ad026f45b49a409f1bad87099ac7 /lib | |
parent | ed71343df8a3d35c2a0fe7d6c91778278f8d7dd1 (diff) | |
download | nextcloud-server-2f1a990cadc5202dd20c3ec87e886685f6733595.tar.gz nextcloud-server-2f1a990cadc5202dd20c3ec87e886685f6733595.zip |
Add search, limit, and offset parameters to getUsers() and getGroups()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/group.php | 8 | ||||
-rw-r--r-- | lib/group/backend.php | 2 | ||||
-rw-r--r-- | lib/group/database.php | 12 | ||||
-rw-r--r-- | lib/group/interface.php | 2 | ||||
-rw-r--r-- | lib/public/user.php | 2 | ||||
-rw-r--r-- | lib/user.php | 12 | ||||
-rw-r--r-- | lib/user/backend.php | 2 | ||||
-rw-r--r-- | lib/user/database.php | 13 | ||||
-rw-r--r-- | lib/user/interface.php | 2 |
9 files changed, 26 insertions, 29 deletions
diff --git a/lib/group.php b/lib/group.php index 12e5f5ebb30..eb6a5828095 100644 --- a/lib/group.php +++ b/lib/group.php @@ -237,10 +237,10 @@ class OC_Group { * * Returns a list with all groups */ - public static function getGroups(){ - $groups=array(); - foreach(self::$_usedBackends as $backend){ - $groups=array_merge($backend->getGroups(),$groups); + public static function getGroups($search = '', $limit = 10, $offset = 0) { + $groups = array(); + foreach (self::$_usedBackends as $backend) { + $groups = array_merge($backend->getGroups($search, $limit, $offset), $groups); } asort($groups); return $groups; diff --git a/lib/group/backend.php b/lib/group/backend.php index ebc078f152a..3f2909caa15 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -105,7 +105,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * * Returns a list with all groups */ - public function getGroups(){ + public function getGroups($search = '', $limit = 10, $offset = 0) { return array(); } diff --git a/lib/group/database.php b/lib/group/database.php index 2770ec185c4..6314a127438 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -164,15 +164,13 @@ class OC_Group_Database extends OC_Group_Backend { * * Returns a list with all groups */ - public function getGroups(){ - $query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups`" ); - $result = $query->execute(); - + public function getGroups($search = '', $limit = 10, $offset = 0) { + $query = OC_DB::prepare('SELECT gid FROM *PREFIX*groups WHERE gid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + $result = $query->execute(array($search.'%')); $groups = array(); - while( $row = $result->fetchRow()){ - $groups[] = $row["gid"]; + while ($row = $result->fetchRow()) { + $groups[] = $row['gid']; } - return $groups; } diff --git a/lib/group/interface.php b/lib/group/interface.php index 7cca6061e10..6e492e72748 100644 --- a/lib/group/interface.php +++ b/lib/group/interface.php @@ -58,7 +58,7 @@ interface OC_Group_Interface { * * Returns a list with all groups */ - public function getGroups(); + public function getGroups($search = '', $limit = 10, $offset = 0); /** * check if a group exists diff --git a/lib/public/user.php b/lib/public/user.php index 713e366b968..178d1dddd36 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -51,7 +51,7 @@ class User { * * Get a list of all users. */ - public static function getUsers(){ + public static function getUsers($search = '', $limit = 10, $offset = 0) { return \OC_USER::getUsers(); } diff --git a/lib/user.php b/lib/user.php index e3c9c23effa..681fd82b99a 100644 --- a/lib/user.php +++ b/lib/user.php @@ -337,12 +337,12 @@ class OC_User { * * Get a list of all users. */ - public static function getUsers(){ - $users=array(); - foreach(self::$_usedBackends as $backend){ - $backendUsers=$backend->getUsers(); - if(is_array($backendUsers)){ - $users=array_merge($users,$backendUsers); + public static function getUsers($search = '', $limit = 10, $offset = 0) { + $users = array(); + foreach (self::$_usedBackends as $backend) { + $backendUsers = $backend->getUsers($search, $limit, $offset); + if (is_array($backendUsers)) { + $users = array_merge($users, $backendUsers); } } asort($users); diff --git a/lib/user/backend.php b/lib/user/backend.php index daa942d261c..ff00ef08f6c 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -97,7 +97,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * * Get a list of all users. */ - public function getUsers(){ + public function getUsers($search = '', $limit = 10, $offset = 0) { return array(); } diff --git a/lib/user/database.php b/lib/user/database.php index cc27b3ddbfd..968814d9d57 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -154,13 +154,12 @@ class OC_User_Database extends OC_User_Backend { * * Get a list of all users. */ - public function getUsers(){ - $query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users" ); - $result = $query->execute(); - - $users=array(); - while( $row = $result->fetchRow()){ - $users[] = $row["uid"]; + public function getUsers($search = '', $limit = 10, $offset = 0) { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*users WHERE uid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + $result = $query->execute(array($search.'%')); + $users = array(); + while ($row = $result->fetchRow()) { + $users[] = $row['uid']; } return $users; } diff --git a/lib/user/interface.php b/lib/user/interface.php index dc3685dc20d..b3286cd2f9e 100644 --- a/lib/user/interface.php +++ b/lib/user/interface.php @@ -48,7 +48,7 @@ interface OC_User_Interface { * * Get a list of all users. */ - public function getUsers(); + public function getUsers($search = '', $limit = 10, $offset = 0); /** * @brief check if a user exists |