Add search, limit, offset parameters to usersInGroups()
This commit is contained in:
parent
4f1b3631ba
commit
a1c88a3e39
|
@ -264,10 +264,10 @@ class OC_Group {
|
||||||
* @brief get a list of all users in a group
|
* @brief get a list of all users in a group
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public static function usersInGroup($gid){
|
public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||||
$users=array();
|
$users=array();
|
||||||
foreach(self::$_usedBackends as $backend){
|
foreach(self::$_usedBackends as $backend){
|
||||||
$users=array_merge($backend->usersInGroup($gid),$users);
|
$users = array_merge($backend->usersInGroup($gid, $search, $limit, $offset), $users);
|
||||||
}
|
}
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
@ -277,10 +277,11 @@ class OC_Group {
|
||||||
* @param array $gids
|
* @param array $gids
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public static function usersInGroups($gids){
|
public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) {
|
||||||
$users = array();
|
$users = array();
|
||||||
foreach($gids as $gid){
|
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;
|
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
|
* @brief get a list of all users in a group
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public function usersInGroup($gid){
|
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,12 +182,16 @@ class OC_Group_Database extends OC_Group_Backend {
|
||||||
* @brief get a list of all users in a group
|
* @brief get a list of all users in a group
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public function usersInGroup($gid){
|
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||||
$query=OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid=?');
|
if ($limit == -1) {
|
||||||
$users=array();
|
$query = OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid = ? AND uid LIKE ?');
|
||||||
$result=$query->execute(array($gid));
|
} else {
|
||||||
while($row=$result->fetchRow()){
|
$query = OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid = ? AND uid LIKE ? LIMIT '.$limit.' OFFSET '.$offset);
|
||||||
$users[]=$row['uid'];
|
}
|
||||||
|
$result = $query->execute(array($gid, $search.'%'));
|
||||||
|
$users = array();
|
||||||
|
while ($row = $result->fetchRow()) {
|
||||||
|
$users[] = $row['uid'];
|
||||||
}
|
}
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ class OC_Group_Dummy extends OC_Group_Backend {
|
||||||
* @brief get a list of all users in a group
|
* @brief get a list of all users in a group
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public function usersInGroup($gid){
|
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
|
||||||
if(isset($this->groups[$gid])){
|
if(isset($this->groups[$gid])){
|
||||||
return $this->groups[$gid];
|
return $this->groups[$gid];
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -104,6 +104,6 @@ abstract class OC_Group_Example {
|
||||||
* @brief get a list of all users in a group
|
* @brief get a list of all users in a group
|
||||||
* @returns array with user ids
|
* @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
|
* @brief get a list of all users in a group
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public function usersInGroup($gid);
|
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0);
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue