Skip to content
Snippets Groups Projects
Commit a1c88a3e authored by Michael Gapczynski's avatar Michael Gapczynski
Browse files

Add search, limit, offset parameters to usersInGroups()

parent 4f1b3631
No related branches found
No related tags found
No related merge requests found
......@@ -264,10 +264,10 @@ class OC_Group {
* @brief get a list of all users in a group
* @returns array with user ids
*/
public static function usersInGroup($gid){
public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$users=array();
foreach(self::$_usedBackends as $backend){
$users=array_merge($backend->usersInGroup($gid),$users);
$users = array_merge($backend->usersInGroup($gid, $search, $limit, $offset), $users);
}
return $users;
}
......@@ -277,10 +277,11 @@ class OC_Group {
* @param array $gids
* @returns array with user ids
*/
public static function usersInGroups($gids){
public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
$users = array();
foreach ($gids as $gid) {
$users = array_merge(array_diff(self::usersInGroup($gid), $users), $users);
// TODO Need to apply limits to groups as total
$users = array_merge(array_diff(self::usersInGroup($gid, $search, $limit, $offset), $users), $users);
}
return $users;
}
......
......@@ -122,7 +122,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
* @brief get a list of all users in a group
* @returns array with user ids
*/
public function usersInGroup($gid){
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
return array();
}
......
......@@ -182,10 +182,14 @@ 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=?');
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();
$result=$query->execute(array($gid));
while ($row = $result->fetchRow()) {
$users[] = $row['uid'];
}
......
......@@ -149,7 +149,7 @@ class OC_Group_Dummy extends OC_Group_Backend {
* @brief get a list of all users in a group
* @returns array with user ids
*/
public function usersInGroup($gid){
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
if(isset($this->groups[$gid])){
return $this->groups[$gid];
}else{
......
......@@ -104,6 +104,6 @@ abstract class OC_Group_Example {
* @brief get a list of all users in a group
* @returns array with user ids
*/
abstract public static function usersInGroup($gid);
abstract public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
}
......@@ -71,6 +71,6 @@ interface OC_Group_Interface {
* @brief get a list of all users in a group
* @returns array with user ids
*/
public function usersInGroup($gid);
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment