Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/provisioning_api/lib/Controller/AUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(string $appName,
/**
* creates a array with all user data
*
* @param $userId
* @param string $userId
* @return array
* @throws OCSException
*/
Expand Down
15 changes: 7 additions & 8 deletions apps/provisioning_api/lib/Controller/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,25 @@ public function getGroupUsers(string $groupId): DataResponse {
* @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)) {
Expand Down
17 changes: 10 additions & 7 deletions apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
Expand Down Expand Up @@ -154,29 +155,31 @@ public function getUsers(string $search = '', $limit = null, $offset = 0): DataR
* 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)) {
Expand Down