Add search, limit, and offset parameters to getUsers() and getGroups()
This commit is contained in:
parent
baa0b4d530
commit
8d1eb674ec
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
12
lib/user.php
12
lib/user.php
|
@ -338,12 +338,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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue