mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
Merge pull request #45370 from nextcloud/feat/add-back-search-in-disabled-users
feat: Add back searching in disabled user list
This commit is contained in:
commit
2fa099a6e1
14 changed files with 62 additions and 20 deletions
|
|
@ -225,13 +225,14 @@ class UsersController extends AUserData {
|
|||
*
|
||||
* Get the list of disabled users and their details
|
||||
*
|
||||
* @param string $search Text to search for
|
||||
* @param ?int $limit Limit the amount of users returned
|
||||
* @param int $offset Offset
|
||||
* @return DataResponse<Http::STATUS_OK, array{users: array<string, Provisioning_APIUserDetails|array{id: string}>}, array{}>
|
||||
*
|
||||
* 200: Disabled users details returned
|
||||
*/
|
||||
public function getDisabledUsersDetails(?int $limit = null, int $offset = 0): DataResponse {
|
||||
public function getDisabledUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
|
||||
$currentUser = $this->userSession->getUser();
|
||||
if ($currentUser === null) {
|
||||
return new DataResponse(['users' => []]);
|
||||
|
|
@ -249,7 +250,7 @@ class UsersController extends AUserData {
|
|||
$uid = $currentUser->getUID();
|
||||
$subAdminManager = $this->groupManager->getSubAdmin();
|
||||
if ($this->groupManager->isAdmin($uid)) {
|
||||
$users = $this->userManager->getDisabledUsers($limit, $offset);
|
||||
$users = $this->userManager->getDisabledUsers($limit, $offset, $search);
|
||||
$users = array_map(fn (IUser $user): string => $user->getUID(), $users);
|
||||
} elseif ($subAdminManager->isSubAdmin($currentUser)) {
|
||||
$subAdminOfGroups = $subAdminManager->getSubAdminsGroups($currentUser);
|
||||
|
|
@ -263,7 +264,7 @@ class UsersController extends AUserData {
|
|||
array_map(
|
||||
fn (IUser $user): string => $user->getUID(),
|
||||
array_filter(
|
||||
$group->searchUsers('', ($tempLimit === null ? null : $tempLimit - count($users))),
|
||||
$group->searchUsers($search, ($tempLimit === null ? null : $tempLimit - count($users))),
|
||||
fn (IUser $user): bool => !$user->isEnabled()
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2279,6 +2279,15 @@
|
|||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "search",
|
||||
"in": "query",
|
||||
"description": "Text to search for",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
|
|
|
|||
|
|
@ -1353,6 +1353,15 @@
|
|||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "search",
|
||||
"in": "query",
|
||||
"description": "Text to search for",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "limit",
|
||||
"in": "query",
|
||||
|
|
|
|||
|
|
@ -313,6 +313,7 @@ export default {
|
|||
await this.$store.dispatch('getDisabledUsers', {
|
||||
offset: this.disabledUsersOffset,
|
||||
limit: this.disabledUsersLimit,
|
||||
search: this.searchQuery,
|
||||
})
|
||||
} else {
|
||||
await this.$store.dispatch('getUsers', {
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@ const actions = {
|
|||
* @param {number} options.limit List number to return from offset
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
async getDisabledUsers(context, { offset, limit }) {
|
||||
const url = generateOcsUrl('cloud/users/disabled?offset={offset}&limit={limit}', { offset, limit })
|
||||
async getDisabledUsers(context, { offset, limit, search }) {
|
||||
const url = generateOcsUrl('cloud/users/disabled?offset={offset}&limit={limit}&search={search}', { offset, limit, search })
|
||||
try {
|
||||
const response = await api.get(url)
|
||||
const usersCount = Object.keys(response.data.ocs.data.users).length
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
|
|||
return $enabled;
|
||||
}
|
||||
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0): array {
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array {
|
||||
throw new \Exception('This is implemented directly in User_Proxy');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -463,11 +463,22 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
|
|||
return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]);
|
||||
}
|
||||
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0): array {
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array {
|
||||
$disabledUsers = $this->deletedUsersIndex->getUsers();
|
||||
if ($search !== '') {
|
||||
$disabledUsers = array_filter(
|
||||
$disabledUsers,
|
||||
fn (OfflineUser $user): bool =>
|
||||
mb_stripos($user->getOCName(), $search) !== false ||
|
||||
mb_stripos($user->getUID(), $search) !== false ||
|
||||
mb_stripos($user->getDisplayName(), $search) !== false ||
|
||||
mb_stripos($user->getEmail(), $search) !== false,
|
||||
);
|
||||
}
|
||||
return array_map(
|
||||
fn (OfflineUser $user) => $user->getOCName(),
|
||||
array_slice(
|
||||
$this->deletedUsersIndex->getUsers(),
|
||||
$disabledUsers,
|
||||
$offset,
|
||||
$limit
|
||||
)
|
||||
|
|
|
|||
6
dist/settings-users-3239.js
vendored
6
dist/settings-users-3239.js
vendored
File diff suppressed because one or more lines are too long
2
dist/settings-users-3239.js.map
vendored
2
dist/settings-users-3239.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -333,7 +333,7 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
/**
|
||||
* @return IUser[]
|
||||
*/
|
||||
public function getDisabledUsers(?int $limit = null, int $offset = 0): array {
|
||||
public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array {
|
||||
$users = $this->config->getUsersForUserValue('core', 'enabled', 'false');
|
||||
$users = array_combine(
|
||||
$users,
|
||||
|
|
@ -342,6 +342,15 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
$users
|
||||
)
|
||||
);
|
||||
if ($search !== '') {
|
||||
$users = array_filter(
|
||||
$users,
|
||||
fn (IUser $user): bool =>
|
||||
mb_stripos($user->getUID(), $search) !== false ||
|
||||
mb_stripos($user->getDisplayName(), $search) !== false ||
|
||||
mb_stripos($user->getEMailAddress() ?? '', $search) !== false,
|
||||
);
|
||||
}
|
||||
|
||||
$tempLimit = ($limit === null ? null : $limit + $offset);
|
||||
foreach ($this->backends as $backend) {
|
||||
|
|
@ -349,7 +358,7 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
break;
|
||||
}
|
||||
if ($backend instanceof IProvideEnabledStateBackend) {
|
||||
$backendUsers = $backend->getDisabledUserList(($tempLimit === null ? null : $tempLimit - count($users)));
|
||||
$backendUsers = $backend->getDisabledUserList(($tempLimit === null ? null : $tempLimit - count($users)), 0, $search);
|
||||
foreach ($backendUsers as $uid) {
|
||||
$users[$uid] = new LazyUser($uid, $this, null, $backend);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,8 +142,9 @@ interface IUserManager {
|
|||
/**
|
||||
* @return IUser[]
|
||||
* @since 28.0.0
|
||||
* @since 30.0.0 $search parameter added
|
||||
*/
|
||||
public function getDisabledUsers(?int $limit = null, int $offset = 0): array;
|
||||
public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array;
|
||||
|
||||
/**
|
||||
* Search known users (from phonebook sync) by displayName
|
||||
|
|
|
|||
|
|
@ -49,8 +49,9 @@ interface IProvideEnabledStateBackend {
|
|||
* Get the list of disabled users, to merge with the ones disabled in database
|
||||
*
|
||||
* @since 28.0.0
|
||||
* @since 30.0.0 $search parameter added
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0): array;
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0, string $search = ''): array;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue