| @@ 865-880 (lines=16) @@ | ||
| 862 | * @return array |
|
| 863 | * @throws OCSException |
|
| 864 | */ |
|
| 865 | protected function getUserSubAdminGroupsData(string $userId): array { |
|
| 866 | $user = $this->userManager->get($userId); |
|
| 867 | // Check if the user exists |
|
| 868 | if($user === null) { |
|
| 869 | throw new OCSException('User does not exist', 101); |
|
| 870 | } |
|
| 871 | ||
| 872 | // Get the subadmin groups |
|
| 873 | $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user); |
|
| 874 | $groups = []; |
|
| 875 | foreach ($subAdminGroups as $key => $group) { |
|
| 876 | $groups[] = $group->getGID(); |
|
| 877 | } |
|
| 878 | ||
| 879 | return $groups; |
|
| 880 | } |
|
| 881 | ||
| 882 | /** |
|
| 883 | * Get the groups a user is a subadmin of |
|
| @@ 211-227 (lines=17) @@ | ||
| 208 | * @return DataResponse |
|
| 209 | * @throws OCSException |
|
| 210 | */ |
|
| 211 | public function getSubAdminsOfGroup(string $groupId): DataResponse { |
|
| 212 | // Check group exists |
|
| 213 | $targetGroup = $this->groupManager->get($groupId); |
|
| 214 | if($targetGroup === null) { |
|
| 215 | throw new OCSException('Group does not exist', 101); |
|
| 216 | } |
|
| 217 | ||
| 218 | /** @var IUser[] $subadmins */ |
|
| 219 | $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup); |
|
| 220 | // New class returns IUser[] so convert back |
|
| 221 | $uids = []; |
|
| 222 | foreach ($subadmins as $user) { |
|
| 223 | $uids[] = $user->getUID(); |
|
| 224 | } |
|
| 225 | ||
| 226 | return new DataResponse($uids); |
|
| 227 | } |
|
| 228 | ||
| 229 | } |
|
| 230 | ||