mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
fix: removed the params related to sortMode and order since it sorts by lastLogin
Signed-off-by: yemkareems <yemkareems@gmail.com>
This commit is contained in:
parent
c701ef1ed5
commit
afa51365ff
5 changed files with 18 additions and 29 deletions
|
|
@ -267,14 +267,13 @@ class UsersController extends AUserData {
|
|||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* Get the list of disabled users and their details
|
||||
* Get the list of last logged-in users and their details
|
||||
*
|
||||
* @param string $search Text to search for
|
||||
* @param ?int $limit Limit the amount of users returned
|
||||
* @param int $offset Offset
|
||||
* @param string $sortMode Field to order the results with
|
||||
* @param string $sortOrder asc or desc
|
||||
* @return DataResponse<Http::STATUS_OK, array{users: array<string, Provisioning_APIUserDetails|array{id: string}>}, array{}>
|
||||
*
|
||||
* 200: Users details returned based on last logged in information
|
||||
|
|
@ -282,8 +281,6 @@ class UsersController extends AUserData {
|
|||
public function getLastLoggedInUsers(string $search = '',
|
||||
?int $limit = null,
|
||||
int $offset = 0,
|
||||
string $sortMode = 'lastLogin',
|
||||
string $sortOrder = 'desc'
|
||||
): DataResponse {
|
||||
$currentUser = $this->userSession->getUser();
|
||||
if ($currentUser === null) {
|
||||
|
|
@ -302,7 +299,7 @@ class UsersController extends AUserData {
|
|||
$uid = $currentUser->getUID();
|
||||
$subAdminManager = $this->groupManager->getSubAdmin();
|
||||
if ($this->groupManager->isAdmin($uid)) {
|
||||
$users = $this->userManager->getUsersSortedByLastLogin($limit, $offset, $search, $sortMode, $sortOrder);
|
||||
$users = $this->userManager->getUsersSortedByLastLogin($limit, $offset, $search);
|
||||
$users = array_map(fn (IUser $user): string => $user->getUID(), $users);
|
||||
} elseif ($subAdminManager->isSubAdmin($currentUser)) {
|
||||
$subAdminOfGroups = $subAdminManager->getSubAdminsGroups($currentUser);
|
||||
|
|
|
|||
|
|
@ -495,29 +495,23 @@ class AllConfig implements IConfig {
|
|||
* Gets the list of users based on their lastLogin info asc or desc
|
||||
*
|
||||
* @param string $search search users based on search params
|
||||
* @param string $sortMode can be lastLogin or any key in preferences
|
||||
* @param string $sortOrder asc or desc
|
||||
* @return array of user IDs
|
||||
*/
|
||||
public function getLastLoggedInUsers($search, $sortMode, $sortOrder): array {
|
||||
public function getLastLoggedInUsers($search): array {
|
||||
// TODO - FIXME
|
||||
$this->fixDIInit();
|
||||
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
|
||||
if ($sortMode === 'lastLogin') {
|
||||
$lastLoginSubSelect = $this->connection->getQueryBuilder();
|
||||
$lastLoginSubSelect->select('configvalue')
|
||||
->from('preferences', 'p2')
|
||||
->where($lastLoginSubSelect->expr()->andX(
|
||||
$lastLoginSubSelect->expr()->eq('p2.userid', 'uid'),
|
||||
$lastLoginSubSelect->expr()->eq('p2.appid', $lastLoginSubSelect->expr()->literal('login')),
|
||||
$lastLoginSubSelect->expr()->eq('p2.configkey', $lastLoginSubSelect->expr()->literal('lastLogin')),
|
||||
));
|
||||
$orderByExpression = $query->createFunction('(' . $lastLoginSubSelect->getSQL() .')');
|
||||
} else {
|
||||
$orderByExpression = $query->func()->lower('displayname');
|
||||
}
|
||||
$lastLoginSubSelect = $this->connection->getQueryBuilder();
|
||||
$lastLoginSubSelect->select('configvalue')
|
||||
->from('preferences', 'p2')
|
||||
->where($lastLoginSubSelect->expr()->andX(
|
||||
$lastLoginSubSelect->expr()->eq('p2.userid', 'uid'),
|
||||
$lastLoginSubSelect->expr()->eq('p2.appid', $lastLoginSubSelect->expr()->literal('login')),
|
||||
$lastLoginSubSelect->expr()->eq('p2.configkey', $lastLoginSubSelect->expr()->literal('lastLogin')),
|
||||
));
|
||||
$orderByExpression = $query->createFunction('(' . $lastLoginSubSelect->getSQL() .')');
|
||||
|
||||
$query->select('uid', 'displayname', $orderByExpression)
|
||||
->from('users', 'u')
|
||||
|
|
@ -530,7 +524,7 @@ class AllConfig implements IConfig {
|
|||
->where($query->expr()->iLike('uid', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%')))
|
||||
->orWhere($query->expr()->iLike('displayname', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%')))
|
||||
->orWhere($query->expr()->iLike('configvalue', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%')))
|
||||
->orderBy($orderByExpression, $sortOrder)
|
||||
->orderBy($orderByExpression, 'DESC')
|
||||
->addOrderBy('uid_lower', 'ASC');
|
||||
|
||||
$result = $query->executeQuery();
|
||||
|
|
|
|||
|
|
@ -345,8 +345,8 @@ class Manager extends PublicEmitter implements IUserManager {
|
|||
/**
|
||||
* @return IUser[]
|
||||
*/
|
||||
public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = '', $sortMode = 'lastLogin', $sortOrder = 'desc'): array {
|
||||
$users = $this->config->getLastLoggedInUsers($search, $sortMode, $sortOrder);
|
||||
public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = ''): array {
|
||||
$users = $this->config->getLastLoggedInUsers($search);
|
||||
$users = array_combine(
|
||||
$users,
|
||||
array_map(
|
||||
|
|
|
|||
|
|
@ -254,10 +254,8 @@ interface IConfig {
|
|||
* Gets the list of users based on their lastLogin info asc or desc
|
||||
*
|
||||
* @param string $search search users based on search params
|
||||
* @param string $sortMode can be lastLogin or any key in preferences
|
||||
* @param string $sortOrder asc or desc
|
||||
* @return array of user IDs
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function getLastLoggedInUsers($search, $sortMode, $sortOrder);
|
||||
public function getLastLoggedInUsers($search);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ interface IUserManager {
|
|||
* @return IUser[]
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = '', $sortMode = 'lastLogin', $sortOrder = 'desc'): array;
|
||||
public function getUsersSortedByLastLogin(?int $limit = null, int $offset = 0, $search = ''): array;
|
||||
/**
|
||||
* Search known users (from phonebook sync) by displayName
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue