diff options
Diffstat (limited to 'lib/group/database.php')
-rw-r--r-- | lib/group/database.php | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/group/database.php b/lib/group/database.php index 2770ec185c4..1cb4171f49f 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -164,15 +164,17 @@ 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 = -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()){ - $groups[] = $row["gid"]; + while ($row = $result->fetchRow()) { + $groups[] = $row['gid']; } - return $groups; } @@ -180,12 +182,16 @@ class OC_Group_Database extends OC_Group_Backend { * @brief get a list of all users in a group * @returns array with user ids */ - public function usersInGroup($gid){ - $query=OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid=?'); - $users=array(); - $result=$query->execute(array($gid)); - while($row=$result->fetchRow()){ - $users[]=$row['uid']; + public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { + if ($limit == -1) { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid = ? AND uid LIKE ?'); + } else { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid = ? AND uid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + } + $result = $query->execute(array($gid, $search.'%')); + $users = array(); + while ($row = $result->fetchRow()) { + $users[] = $row['uid']; } return $users; } |