Merge pull request #11186 from nextcloud/backport/11181/user-list-broken-with-integer-only-users
[stable14] Fix user and group listing with users that have an integer user id
This commit is contained in:
commit
8e3e25a057
|
@ -74,7 +74,7 @@ abstract class AUserData extends OCSController {
|
|||
/**
|
||||
* creates a array with all user data
|
||||
*
|
||||
* @param $userId
|
||||
* @param string $userId
|
||||
* @return array
|
||||
* @throws OCSException
|
||||
*/
|
||||
|
|
|
@ -186,26 +186,25 @@ class GroupsController extends AUserData {
|
|||
* @throws OCSException
|
||||
*/
|
||||
public function getGroupUsersDetails(string $groupId, string $search = '', int $limit = null, int $offset = 0): DataResponse {
|
||||
$user = $this->userSession->getUser();
|
||||
$isSubadminOfGroup = false;
|
||||
$currentUser = $this->userSession->getUser();
|
||||
|
||||
// Check the group exists
|
||||
$group = $this->groupManager->get($groupId);
|
||||
if ($group !== null) {
|
||||
$isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group);
|
||||
$isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($currentUser, $group);
|
||||
} else {
|
||||
throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Check subadmin has access to this group
|
||||
if($this->groupManager->isAdmin($user->getUID())
|
||||
|| $isSubadminOfGroup) {
|
||||
$users = $this->groupManager->get($groupId)->searchUsers($search, $limit, $offset);
|
||||
if($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) {
|
||||
$users = $group->searchUsers($search, $limit, $offset);
|
||||
|
||||
// Extract required number
|
||||
$users = array_keys($users);
|
||||
$usersDetails = [];
|
||||
foreach ($users as $userId) {
|
||||
foreach ($users as $user) {
|
||||
/** @var IUser $user */
|
||||
$userId = (string) $user->getUID();
|
||||
$userData = $this->getUserData($userId);
|
||||
// Do not insert empty entry
|
||||
if(!empty($userData)) {
|
||||
|
|
|
@ -46,6 +46,7 @@ use OCP\IGroup;
|
|||
use OCP\IGroupManager;
|
||||
use OCP\ILogger;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
|
@ -154,29 +155,31 @@ class UsersController extends AUserData {
|
|||
* returns a list of users and their data
|
||||
*/
|
||||
public function getUsersDetails(string $search = '', $limit = null, $offset = 0): DataResponse {
|
||||
$user = $this->userSession->getUser();
|
||||
$currentUser = $this->userSession->getUser();
|
||||
$users = [];
|
||||
|
||||
// Admin? Or SubAdmin?
|
||||
$uid = $user->getUID();
|
||||
$uid = $currentUser->getUID();
|
||||
$subAdminManager = $this->groupManager->getSubAdmin();
|
||||
if ($this->groupManager->isAdmin($uid)){
|
||||
$users = $this->userManager->search($search, $limit, $offset);
|
||||
} else if ($subAdminManager->isSubAdmin($user)) {
|
||||
$subAdminOfGroups = $subAdminManager->getSubAdminsGroups($user);
|
||||
$users = array_keys($users);
|
||||
} else if ($subAdminManager->isSubAdmin($currentUser)) {
|
||||
$subAdminOfGroups = $subAdminManager->getSubAdminsGroups($currentUser);
|
||||
foreach ($subAdminOfGroups as $key => $group) {
|
||||
$subAdminOfGroups[$key] = $group->getGID();
|
||||
}
|
||||
|
||||
$users = [];
|
||||
foreach ($subAdminOfGroups as $group) {
|
||||
$users = array_merge($users, $this->groupManager->displayNamesInGroup($group, $search, $limit, $offset));
|
||||
$users[] = array_keys($this->groupManager->displayNamesInGroup($group, $search, $limit, $offset));
|
||||
}
|
||||
$users = array_merge(...$users);
|
||||
}
|
||||
|
||||
$users = array_keys($users);
|
||||
$usersDetails = [];
|
||||
foreach ($users as $key => $userId) {
|
||||
foreach ($users as $userId) {
|
||||
$userId = (string) $userId;
|
||||
$userData = $this->getUserData($userId);
|
||||
// Do not insert empty entry
|
||||
if (!empty($userData)) {
|
||||
|
|
Loading…
Reference in New Issue