From 874f31b8d773cc0df3572c275d1ac42642a7f719 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Sat, 11 Aug 2012 16:06:31 -0400 Subject: [PATCH] Make getting all users and groups the default --- lib/group.php | 2 +- lib/group/backend.php | 2 +- lib/group/database.php | 8 ++++++-- lib/group/dummy.php | 2 +- lib/group/example.php | 2 +- lib/group/interface.php | 2 +- lib/public/user.php | 2 +- lib/user/backend.php | 2 +- lib/user/database.php | 8 ++++++-- lib/user/dummy.php | 2 +- lib/user/interface.php | 2 +- 11 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/group.php b/lib/group.php index a3bdbf9e00..e47b770f59 100644 --- a/lib/group.php +++ b/lib/group.php @@ -237,7 +237,7 @@ class OC_Group { * * Returns a list with all groups */ - public static function getGroups($search = '', $limit = 10, $offset = 0) { + public static function getGroups($search = '', $limit = -1, $offset = 0) { $groups = array(); foreach (self::$_usedBackends as $backend) { $groups = array_merge($backend->getGroups($search, $limit, $offset), $groups); diff --git a/lib/group/backend.php b/lib/group/backend.php index 3f2909caa1..7a7cebc726 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($search = '', $limit = 10, $offset = 0) { + public function getGroups($search = '', $limit = -1, $offset = 0) { return array(); } diff --git a/lib/group/database.php b/lib/group/database.php index 6314a12743..669edc662c 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -164,8 +164,12 @@ class OC_Group_Database extends OC_Group_Backend { * * Returns a list with all groups */ - public function getGroups($search = '', $limit = 10, $offset = 0) { - $query = OC_DB::prepare('SELECT gid FROM *PREFIX*groups WHERE gid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + public function getGroups($search = '', $limit = -1, $offset = 0) { + if ($limit == -1) { + $query = OC_DB::prepare('SELECT gid FROM *PREFIX*groups WHERE gid LIKE ?'); + } else { + $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()) { diff --git a/lib/group/dummy.php b/lib/group/dummy.php index 1243891023..092aa9beda 100644 --- a/lib/group/dummy.php +++ b/lib/group/dummy.php @@ -141,7 +141,7 @@ class OC_Group_Dummy extends OC_Group_Backend { * * Returns a list with all groups */ - public function getGroups(){ + public function getGroups($search = '', $limit = -1, $offset = 0) { return array_keys($this->groups); } diff --git a/lib/group/example.php b/lib/group/example.php index 9c9ece5ac7..c33b435ca0 100644 --- a/lib/group/example.php +++ b/lib/group/example.php @@ -91,7 +91,7 @@ abstract class OC_Group_Example { * * Returns a list with all groups */ - abstract public static function getGroups(); + abstract public static function getGroups($search = '', $limit = -1, $offset = 0); /** * check if a group exists diff --git a/lib/group/interface.php b/lib/group/interface.php index 6e492e7274..f496d502df 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($search = '', $limit = 10, $offset = 0); + public function getGroups($search = '', $limit = -1, $offset = 0); /** * check if a group exists diff --git a/lib/public/user.php b/lib/public/user.php index 178d1dddd3..2fa599488a 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($search = '', $limit = 10, $offset = 0) { + public static function getUsers($search = '', $limit = -1, $offset = 0) { return \OC_USER::getUsers(); } diff --git a/lib/user/backend.php b/lib/user/backend.php index ff00ef08f6..f67908cdac 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($search = '', $limit = 10, $offset = 0) { + public function getUsers($search = '', $limit = -1, $offset = 0) { return array(); } diff --git a/lib/user/database.php b/lib/user/database.php index 968814d9d5..1deed51761 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -154,8 +154,12 @@ class OC_User_Database extends OC_User_Backend { * * Get a list of all users. */ - public function getUsers($search = '', $limit = 10, $offset = 0) { - $query = OC_DB::prepare('SELECT uid FROM *PREFIX*users WHERE uid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + public function getUsers($search = '', $limit = -1, $offset = 0) { + if ($limit == -1) { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*users WHERE uid LIKE ?'); + } else { + $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()) { diff --git a/lib/user/dummy.php b/lib/user/dummy.php index a946d4e621..da3edfb2df 100644 --- a/lib/user/dummy.php +++ b/lib/user/dummy.php @@ -100,7 +100,7 @@ class OC_User_Dummy extends OC_User_Backend { * * Get a list of all users. */ - public function getUsers(){ + public function getUsers($search = '', $limit = -1, $offset = 0) { return array_keys($this->users); } diff --git a/lib/user/interface.php b/lib/user/interface.php index b3286cd2f9..a4903898fb 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($search = '', $limit = 10, $offset = 0); + public function getUsers($search = '', $limit = -1, $offset = 0); /** * @brief check if a user exists