@@ -48,278 +48,278 @@ |
||
| 48 | 48 | |
| 49 | 49 | class GroupsController extends AUserData { |
| 50 | 50 | |
| 51 | - /** @var ILogger */ |
|
| 52 | - private $logger; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @param string $appName |
|
| 56 | - * @param IRequest $request |
|
| 57 | - * @param IUserManager $userManager |
|
| 58 | - * @param IConfig $config |
|
| 59 | - * @param IGroupManager $groupManager |
|
| 60 | - * @param IUserSession $userSession |
|
| 61 | - * @param AccountManager $accountManager |
|
| 62 | - * @param ILogger $logger |
|
| 63 | - * @param UsersController $userController |
|
| 64 | - */ |
|
| 65 | - public function __construct(string $appName, |
|
| 66 | - IRequest $request, |
|
| 67 | - IUserManager $userManager, |
|
| 68 | - IConfig $config, |
|
| 69 | - IGroupManager $groupManager, |
|
| 70 | - IUserSession $userSession, |
|
| 71 | - AccountManager $accountManager, |
|
| 72 | - ILogger $logger) { |
|
| 73 | - parent::__construct($appName, |
|
| 74 | - $request, |
|
| 75 | - $userManager, |
|
| 76 | - $config, |
|
| 77 | - $groupManager, |
|
| 78 | - $userSession, |
|
| 79 | - $accountManager); |
|
| 80 | - |
|
| 81 | - $this->logger = $logger; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * returns a list of groups |
|
| 86 | - * |
|
| 87 | - * @NoAdminRequired |
|
| 88 | - * |
|
| 89 | - * @param string $search |
|
| 90 | - * @param int $limit |
|
| 91 | - * @param int $offset |
|
| 92 | - * @return DataResponse |
|
| 93 | - */ |
|
| 94 | - public function getGroups(string $search = '', int $limit = null, int $offset = 0): DataResponse { |
|
| 95 | - $groups = $this->groupManager->search($search, $limit, $offset); |
|
| 96 | - $groups = array_map(function ($group) { |
|
| 97 | - /** @var IGroup $group */ |
|
| 98 | - return $group->getGID(); |
|
| 99 | - }, $groups); |
|
| 100 | - |
|
| 101 | - return new DataResponse(['groups' => $groups]); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * returns a list of groups details with ids and displaynames |
|
| 106 | - * |
|
| 107 | - * @NoAdminRequired |
|
| 108 | - * |
|
| 109 | - * @param string $search |
|
| 110 | - * @param int $limit |
|
| 111 | - * @param int $offset |
|
| 112 | - * @return DataResponse |
|
| 113 | - */ |
|
| 114 | - public function getGroupsDetails(string $search = '', int $limit = null, int $offset = 0): DataResponse { |
|
| 115 | - $groups = $this->groupManager->search($search, $limit, $offset); |
|
| 116 | - $groups = array_map(function ($group) { |
|
| 117 | - /** @var IGroup $group */ |
|
| 118 | - return [ |
|
| 119 | - 'id' => $group->getGID(), |
|
| 120 | - 'displayname' => $group->getDisplayName(), |
|
| 121 | - 'usercount' => $group->count(), |
|
| 122 | - 'disabled' => $group->countDisabled(), |
|
| 123 | - 'canAdd' => $group->canAddUser(), |
|
| 124 | - 'canRemove' => $group->canRemoveUser(), |
|
| 125 | - ]; |
|
| 126 | - }, $groups); |
|
| 127 | - |
|
| 128 | - return new DataResponse(['groups' => $groups]); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @NoAdminRequired |
|
| 133 | - * |
|
| 134 | - * @param string $groupId |
|
| 135 | - * @return DataResponse |
|
| 136 | - * @throws OCSException |
|
| 137 | - * |
|
| 138 | - * @deprecated 14 Use getGroupUsers |
|
| 139 | - */ |
|
| 140 | - public function getGroup(string $groupId): DataResponse { |
|
| 141 | - return $this->getGroupUsers($groupId); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * returns an array of users in the specified group |
|
| 146 | - * |
|
| 147 | - * @NoAdminRequired |
|
| 148 | - * |
|
| 149 | - * @param string $groupId |
|
| 150 | - * @return DataResponse |
|
| 151 | - * @throws OCSException |
|
| 152 | - */ |
|
| 153 | - public function getGroupUsers(string $groupId): DataResponse { |
|
| 154 | - $groupId = urldecode($groupId); |
|
| 155 | - |
|
| 156 | - $user = $this->userSession->getUser(); |
|
| 157 | - $isSubadminOfGroup = false; |
|
| 158 | - |
|
| 159 | - // Check the group exists |
|
| 160 | - $group = $this->groupManager->get($groupId); |
|
| 161 | - if ($group !== null) { |
|
| 162 | - $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 163 | - } else { |
|
| 164 | - throw new OCSNotFoundException('The requested group could not be found'); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // Check subadmin has access to this group |
|
| 168 | - if ($this->groupManager->isAdmin($user->getUID()) |
|
| 169 | - || $isSubadminOfGroup) { |
|
| 170 | - $users = $this->groupManager->get($groupId)->getUsers(); |
|
| 171 | - $users = array_map(function ($user) { |
|
| 172 | - /** @var IUser $user */ |
|
| 173 | - return $user->getUID(); |
|
| 174 | - }, $users); |
|
| 175 | - $users = array_values($users); |
|
| 176 | - return new DataResponse(['users' => $users]); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - throw new OCSForbiddenException(); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * returns an array of users details in the specified group |
|
| 184 | - * |
|
| 185 | - * @NoAdminRequired |
|
| 186 | - * |
|
| 187 | - * @param string $groupId |
|
| 188 | - * @param string $search |
|
| 189 | - * @param int $limit |
|
| 190 | - * @param int $offset |
|
| 191 | - * @return DataResponse |
|
| 192 | - * @throws OCSException |
|
| 193 | - */ |
|
| 194 | - public function getGroupUsersDetails(string $groupId, string $search = '', int $limit = null, int $offset = 0): DataResponse { |
|
| 195 | - $groupId = urldecode($groupId); |
|
| 196 | - $currentUser = $this->userSession->getUser(); |
|
| 197 | - |
|
| 198 | - // Check the group exists |
|
| 199 | - $group = $this->groupManager->get($groupId); |
|
| 200 | - if ($group !== null) { |
|
| 201 | - $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($currentUser, $group); |
|
| 202 | - } else { |
|
| 203 | - throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - // Check subadmin has access to this group |
|
| 207 | - if ($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) { |
|
| 208 | - $users = $group->searchUsers($search, $limit, $offset); |
|
| 209 | - |
|
| 210 | - // Extract required number |
|
| 211 | - $usersDetails = []; |
|
| 212 | - foreach ($users as $user) { |
|
| 213 | - try { |
|
| 214 | - /** @var IUser $user */ |
|
| 215 | - $userId = (string)$user->getUID(); |
|
| 216 | - $userData = $this->getUserData($userId); |
|
| 217 | - // Do not insert empty entry |
|
| 218 | - if (!empty($userData)) { |
|
| 219 | - $usersDetails[$userId] = $userData; |
|
| 220 | - } else { |
|
| 221 | - // Logged user does not have permissions to see this user |
|
| 222 | - // only showing its id |
|
| 223 | - $usersDetails[$userId] = ['id' => $userId]; |
|
| 224 | - } |
|
| 225 | - } catch (OCSNotFoundException $e) { |
|
| 226 | - // continue if a users ceased to exist. |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - return new DataResponse(['users' => $usersDetails]); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * creates a new group |
|
| 237 | - * |
|
| 238 | - * @PasswordConfirmationRequired |
|
| 239 | - * |
|
| 240 | - * @param string $groupid |
|
| 241 | - * @return DataResponse |
|
| 242 | - * @throws OCSException |
|
| 243 | - */ |
|
| 244 | - public function addGroup(string $groupid): DataResponse { |
|
| 245 | - // Validate name |
|
| 246 | - if (empty($groupid)) { |
|
| 247 | - $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); |
|
| 248 | - throw new OCSException('Invalid group name', 101); |
|
| 249 | - } |
|
| 250 | - // Check if it exists |
|
| 251 | - if ($this->groupManager->groupExists($groupid)) { |
|
| 252 | - throw new OCSException('group exists', 102); |
|
| 253 | - } |
|
| 254 | - $this->groupManager->createGroup($groupid); |
|
| 255 | - return new DataResponse(); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * @PasswordConfirmationRequired |
|
| 260 | - * |
|
| 261 | - * @param string $groupId |
|
| 262 | - * @param string $key |
|
| 263 | - * @param string $value |
|
| 264 | - * @return DataResponse |
|
| 265 | - * @throws OCSException |
|
| 266 | - */ |
|
| 267 | - public function updateGroup(string $groupId, string $key, string $value): DataResponse { |
|
| 268 | - $groupId = urldecode($groupId); |
|
| 269 | - |
|
| 270 | - if ($key === 'displayname') { |
|
| 271 | - $group = $this->groupManager->get($groupId); |
|
| 272 | - if ($group->setDisplayName($value)) { |
|
| 273 | - return new DataResponse(); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - throw new OCSException('Not supported by backend', 101); |
|
| 277 | - } else { |
|
| 278 | - throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * @PasswordConfirmationRequired |
|
| 284 | - * |
|
| 285 | - * @param string $groupId |
|
| 286 | - * @return DataResponse |
|
| 287 | - * @throws OCSException |
|
| 288 | - */ |
|
| 289 | - public function deleteGroup(string $groupId): DataResponse { |
|
| 290 | - $groupId = urldecode($groupId); |
|
| 291 | - |
|
| 292 | - // Check it exists |
|
| 293 | - if (!$this->groupManager->groupExists($groupId)) { |
|
| 294 | - throw new OCSException('', 101); |
|
| 295 | - } elseif ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { |
|
| 296 | - // Cannot delete admin group |
|
| 297 | - throw new OCSException('', 102); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - return new DataResponse(); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * @param string $groupId |
|
| 305 | - * @return DataResponse |
|
| 306 | - * @throws OCSException |
|
| 307 | - */ |
|
| 308 | - public function getSubAdminsOfGroup(string $groupId): DataResponse { |
|
| 309 | - // Check group exists |
|
| 310 | - $targetGroup = $this->groupManager->get($groupId); |
|
| 311 | - if ($targetGroup === null) { |
|
| 312 | - throw new OCSException('Group does not exist', 101); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** @var IUser[] $subadmins */ |
|
| 316 | - $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup); |
|
| 317 | - // New class returns IUser[] so convert back |
|
| 318 | - $uids = []; |
|
| 319 | - foreach ($subadmins as $user) { |
|
| 320 | - $uids[] = $user->getUID(); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - return new DataResponse($uids); |
|
| 324 | - } |
|
| 51 | + /** @var ILogger */ |
|
| 52 | + private $logger; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param string $appName |
|
| 56 | + * @param IRequest $request |
|
| 57 | + * @param IUserManager $userManager |
|
| 58 | + * @param IConfig $config |
|
| 59 | + * @param IGroupManager $groupManager |
|
| 60 | + * @param IUserSession $userSession |
|
| 61 | + * @param AccountManager $accountManager |
|
| 62 | + * @param ILogger $logger |
|
| 63 | + * @param UsersController $userController |
|
| 64 | + */ |
|
| 65 | + public function __construct(string $appName, |
|
| 66 | + IRequest $request, |
|
| 67 | + IUserManager $userManager, |
|
| 68 | + IConfig $config, |
|
| 69 | + IGroupManager $groupManager, |
|
| 70 | + IUserSession $userSession, |
|
| 71 | + AccountManager $accountManager, |
|
| 72 | + ILogger $logger) { |
|
| 73 | + parent::__construct($appName, |
|
| 74 | + $request, |
|
| 75 | + $userManager, |
|
| 76 | + $config, |
|
| 77 | + $groupManager, |
|
| 78 | + $userSession, |
|
| 79 | + $accountManager); |
|
| 80 | + |
|
| 81 | + $this->logger = $logger; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * returns a list of groups |
|
| 86 | + * |
|
| 87 | + * @NoAdminRequired |
|
| 88 | + * |
|
| 89 | + * @param string $search |
|
| 90 | + * @param int $limit |
|
| 91 | + * @param int $offset |
|
| 92 | + * @return DataResponse |
|
| 93 | + */ |
|
| 94 | + public function getGroups(string $search = '', int $limit = null, int $offset = 0): DataResponse { |
|
| 95 | + $groups = $this->groupManager->search($search, $limit, $offset); |
|
| 96 | + $groups = array_map(function ($group) { |
|
| 97 | + /** @var IGroup $group */ |
|
| 98 | + return $group->getGID(); |
|
| 99 | + }, $groups); |
|
| 100 | + |
|
| 101 | + return new DataResponse(['groups' => $groups]); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * returns a list of groups details with ids and displaynames |
|
| 106 | + * |
|
| 107 | + * @NoAdminRequired |
|
| 108 | + * |
|
| 109 | + * @param string $search |
|
| 110 | + * @param int $limit |
|
| 111 | + * @param int $offset |
|
| 112 | + * @return DataResponse |
|
| 113 | + */ |
|
| 114 | + public function getGroupsDetails(string $search = '', int $limit = null, int $offset = 0): DataResponse { |
|
| 115 | + $groups = $this->groupManager->search($search, $limit, $offset); |
|
| 116 | + $groups = array_map(function ($group) { |
|
| 117 | + /** @var IGroup $group */ |
|
| 118 | + return [ |
|
| 119 | + 'id' => $group->getGID(), |
|
| 120 | + 'displayname' => $group->getDisplayName(), |
|
| 121 | + 'usercount' => $group->count(), |
|
| 122 | + 'disabled' => $group->countDisabled(), |
|
| 123 | + 'canAdd' => $group->canAddUser(), |
|
| 124 | + 'canRemove' => $group->canRemoveUser(), |
|
| 125 | + ]; |
|
| 126 | + }, $groups); |
|
| 127 | + |
|
| 128 | + return new DataResponse(['groups' => $groups]); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @NoAdminRequired |
|
| 133 | + * |
|
| 134 | + * @param string $groupId |
|
| 135 | + * @return DataResponse |
|
| 136 | + * @throws OCSException |
|
| 137 | + * |
|
| 138 | + * @deprecated 14 Use getGroupUsers |
|
| 139 | + */ |
|
| 140 | + public function getGroup(string $groupId): DataResponse { |
|
| 141 | + return $this->getGroupUsers($groupId); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * returns an array of users in the specified group |
|
| 146 | + * |
|
| 147 | + * @NoAdminRequired |
|
| 148 | + * |
|
| 149 | + * @param string $groupId |
|
| 150 | + * @return DataResponse |
|
| 151 | + * @throws OCSException |
|
| 152 | + */ |
|
| 153 | + public function getGroupUsers(string $groupId): DataResponse { |
|
| 154 | + $groupId = urldecode($groupId); |
|
| 155 | + |
|
| 156 | + $user = $this->userSession->getUser(); |
|
| 157 | + $isSubadminOfGroup = false; |
|
| 158 | + |
|
| 159 | + // Check the group exists |
|
| 160 | + $group = $this->groupManager->get($groupId); |
|
| 161 | + if ($group !== null) { |
|
| 162 | + $isSubadminOfGroup =$this->groupManager->getSubAdmin()->isSubAdminOfGroup($user, $group); |
|
| 163 | + } else { |
|
| 164 | + throw new OCSNotFoundException('The requested group could not be found'); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // Check subadmin has access to this group |
|
| 168 | + if ($this->groupManager->isAdmin($user->getUID()) |
|
| 169 | + || $isSubadminOfGroup) { |
|
| 170 | + $users = $this->groupManager->get($groupId)->getUsers(); |
|
| 171 | + $users = array_map(function ($user) { |
|
| 172 | + /** @var IUser $user */ |
|
| 173 | + return $user->getUID(); |
|
| 174 | + }, $users); |
|
| 175 | + $users = array_values($users); |
|
| 176 | + return new DataResponse(['users' => $users]); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + throw new OCSForbiddenException(); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * returns an array of users details in the specified group |
|
| 184 | + * |
|
| 185 | + * @NoAdminRequired |
|
| 186 | + * |
|
| 187 | + * @param string $groupId |
|
| 188 | + * @param string $search |
|
| 189 | + * @param int $limit |
|
| 190 | + * @param int $offset |
|
| 191 | + * @return DataResponse |
|
| 192 | + * @throws OCSException |
|
| 193 | + */ |
|
| 194 | + public function getGroupUsersDetails(string $groupId, string $search = '', int $limit = null, int $offset = 0): DataResponse { |
|
| 195 | + $groupId = urldecode($groupId); |
|
| 196 | + $currentUser = $this->userSession->getUser(); |
|
| 197 | + |
|
| 198 | + // Check the group exists |
|
| 199 | + $group = $this->groupManager->get($groupId); |
|
| 200 | + if ($group !== null) { |
|
| 201 | + $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminOfGroup($currentUser, $group); |
|
| 202 | + } else { |
|
| 203 | + throw new OCSException('The requested group could not be found', \OCP\API::RESPOND_NOT_FOUND); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + // Check subadmin has access to this group |
|
| 207 | + if ($this->groupManager->isAdmin($currentUser->getUID()) || $isSubadminOfGroup) { |
|
| 208 | + $users = $group->searchUsers($search, $limit, $offset); |
|
| 209 | + |
|
| 210 | + // Extract required number |
|
| 211 | + $usersDetails = []; |
|
| 212 | + foreach ($users as $user) { |
|
| 213 | + try { |
|
| 214 | + /** @var IUser $user */ |
|
| 215 | + $userId = (string)$user->getUID(); |
|
| 216 | + $userData = $this->getUserData($userId); |
|
| 217 | + // Do not insert empty entry |
|
| 218 | + if (!empty($userData)) { |
|
| 219 | + $usersDetails[$userId] = $userData; |
|
| 220 | + } else { |
|
| 221 | + // Logged user does not have permissions to see this user |
|
| 222 | + // only showing its id |
|
| 223 | + $usersDetails[$userId] = ['id' => $userId]; |
|
| 224 | + } |
|
| 225 | + } catch (OCSNotFoundException $e) { |
|
| 226 | + // continue if a users ceased to exist. |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + return new DataResponse(['users' => $usersDetails]); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + throw new OCSException('User does not have access to specified group', \OCP\API::RESPOND_UNAUTHORISED); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * creates a new group |
|
| 237 | + * |
|
| 238 | + * @PasswordConfirmationRequired |
|
| 239 | + * |
|
| 240 | + * @param string $groupid |
|
| 241 | + * @return DataResponse |
|
| 242 | + * @throws OCSException |
|
| 243 | + */ |
|
| 244 | + public function addGroup(string $groupid): DataResponse { |
|
| 245 | + // Validate name |
|
| 246 | + if (empty($groupid)) { |
|
| 247 | + $this->logger->error('Group name not supplied', ['app' => 'provisioning_api']); |
|
| 248 | + throw new OCSException('Invalid group name', 101); |
|
| 249 | + } |
|
| 250 | + // Check if it exists |
|
| 251 | + if ($this->groupManager->groupExists($groupid)) { |
|
| 252 | + throw new OCSException('group exists', 102); |
|
| 253 | + } |
|
| 254 | + $this->groupManager->createGroup($groupid); |
|
| 255 | + return new DataResponse(); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * @PasswordConfirmationRequired |
|
| 260 | + * |
|
| 261 | + * @param string $groupId |
|
| 262 | + * @param string $key |
|
| 263 | + * @param string $value |
|
| 264 | + * @return DataResponse |
|
| 265 | + * @throws OCSException |
|
| 266 | + */ |
|
| 267 | + public function updateGroup(string $groupId, string $key, string $value): DataResponse { |
|
| 268 | + $groupId = urldecode($groupId); |
|
| 269 | + |
|
| 270 | + if ($key === 'displayname') { |
|
| 271 | + $group = $this->groupManager->get($groupId); |
|
| 272 | + if ($group->setDisplayName($value)) { |
|
| 273 | + return new DataResponse(); |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + throw new OCSException('Not supported by backend', 101); |
|
| 277 | + } else { |
|
| 278 | + throw new OCSException('', \OCP\API::RESPOND_UNAUTHORISED); |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * @PasswordConfirmationRequired |
|
| 284 | + * |
|
| 285 | + * @param string $groupId |
|
| 286 | + * @return DataResponse |
|
| 287 | + * @throws OCSException |
|
| 288 | + */ |
|
| 289 | + public function deleteGroup(string $groupId): DataResponse { |
|
| 290 | + $groupId = urldecode($groupId); |
|
| 291 | + |
|
| 292 | + // Check it exists |
|
| 293 | + if (!$this->groupManager->groupExists($groupId)) { |
|
| 294 | + throw new OCSException('', 101); |
|
| 295 | + } elseif ($groupId === 'admin' || !$this->groupManager->get($groupId)->delete()) { |
|
| 296 | + // Cannot delete admin group |
|
| 297 | + throw new OCSException('', 102); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + return new DataResponse(); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * @param string $groupId |
|
| 305 | + * @return DataResponse |
|
| 306 | + * @throws OCSException |
|
| 307 | + */ |
|
| 308 | + public function getSubAdminsOfGroup(string $groupId): DataResponse { |
|
| 309 | + // Check group exists |
|
| 310 | + $targetGroup = $this->groupManager->get($groupId); |
|
| 311 | + if ($targetGroup === null) { |
|
| 312 | + throw new OCSException('Group does not exist', 101); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** @var IUser[] $subadmins */ |
|
| 316 | + $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup); |
|
| 317 | + // New class returns IUser[] so convert back |
|
| 318 | + $uids = []; |
|
| 319 | + foreach ($subadmins as $user) { |
|
| 320 | + $uids[] = $user->getUID(); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + return new DataResponse($uids); |
|
| 324 | + } |
|
| 325 | 325 | } |