Remove deprecated \OCP\User::getUsers

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-03-25 20:33:24 +02:00
parent 89ebb8a663
commit 6c8caa1641
No known key found for this signature in database
GPG Key ID: F941078878347C0C
4 changed files with 19 additions and 39 deletions

View File

@ -489,13 +489,22 @@ class User_LDAPTest extends TestCase {
$this->assertEquals(0, count($result));
}
private function getUsers($search = '', $limit = null, $offset = null) {
$users = \OC::$server->getUserManager()->search($search, $limit, $offset);
$uids = [];
foreach ($users as $user) {
$uids[] = $user->getUID();
}
return $uids;
}
public function testGetUsersViaAPINoParam() {
$access = $this->getAccessMock();
$this->prepareAccessForGetUsers($access);
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers();
$result = $this->getUsers();
$this->assertEquals(3, count($result));
}
@ -505,7 +514,7 @@ class User_LDAPTest extends TestCase {
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 1, 2);
$result = $this->getUsers('', 1, 2);
$this->assertEquals(1, count($result));
}
@ -515,7 +524,7 @@ class User_LDAPTest extends TestCase {
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('', 2, 1);
$result = $this->getUsers('', 2, 1);
$this->assertEquals(2, count($result));
}
@ -525,7 +534,7 @@ class User_LDAPTest extends TestCase {
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('yo');
$result = $this->getUsers('yo');
$this->assertEquals(2, count($result));
}
@ -535,7 +544,7 @@ class User_LDAPTest extends TestCase {
$backend = new UserLDAP($access, $this->createMock(IConfig::class), $this->createMock(INotificationManager::class), $this->createMock(Session::class), $this->getDefaultPluginManagerMock());
\OC_User::useBackend($backend);
$result = \OCP\User::getUsers('nix');
$result = $this->getUsers('nix');
$this->assertEquals(0, count($result));
}

View File

@ -271,9 +271,12 @@ class Util {
}
public function getUserWithAccessToMountPoint($users, $groups) {
$result = array();
$result = [];
if (in_array('all', $users)) {
$result = \OCP\User::getUsers();
$users = $this->userManager->search('', null, null);
foreach ($users as $user) {
$result[] = $user->getUID();
}
} else {
$result = array_merge($result, $users);

View File

@ -366,25 +366,6 @@ class OC_User {
}
}
/**
* Get a list of all users
*
* @return array an array of all uids
*
* Get a list of all users.
* @param string $search
* @param integer $limit
* @param integer $offset
*/
public static function getUsers($search = '', $limit = null, $offset = null) {
$users = \OC::$server->getUserManager()->search($search, $limit, $offset);
$uids = array();
foreach ($users as $user) {
$uids[] = $user->getUID();
}
return $uids;
}
/**
* Get a list of all users display name
*

View File

@ -57,19 +57,6 @@ class User {
return \OC_User::getUser();
}
/**
* Get a list of all users
* @param string $search search pattern
* @param int|null $limit
* @param int|null $offset
* @return array an array of all uids
* @deprecated 8.1.0 use method search() of \OCP\IUserManager - \OC::$server->getUserManager()
* @since 5.0.0
*/
public static function getUsers( $search = '', $limit = null, $offset = null ) {
return \OC_User::getUsers( $search, $limit, $offset );
}
/**
* Get the user display name of the user currently logged in.
* @param string|null $user user id or null for current user