diff options
Diffstat (limited to 'apps/provisioning_api/lib/Controller/UsersController.php')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index b0cd9bfb448..9363b4ca935 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -97,7 +97,7 @@ class UsersController extends AUserData { * @param string $search Text to search for * @param int|null $limit Limit the amount of groups returned * @param int $offset Offset for searching for groups - * @return DataResponse<Http::STATUS_OK, array{users: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{users: list<string>}, array{}> * * 200: Users returned */ @@ -125,7 +125,7 @@ class UsersController extends AUserData { } } - /** @var string[] $users */ + /** @var list<string> $users */ $users = array_keys($users); return new DataResponse([ @@ -341,8 +341,8 @@ class UsersController extends AUserData { * Search users by their phone numbers * * @param string $location Location of the phone number (for country code) - * @param array<string, string[]> $search Phone numbers to search for - * @return DataResponse<Http::STATUS_OK, array<string, string>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array<empty>, array{}> + * @param array<string, list<string>> $search Phone numbers to search for + * @return DataResponse<Http::STATUS_OK, array<string, string>, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, list<empty>, array{}> * * 200: Users returned * 400: Invalid location @@ -433,8 +433,8 @@ class UsersController extends AUserData { * @param string $password Password of the user * @param string $displayName Display name of the user * @param string $email Email of the user - * @param string[] $groups Groups of the user - * @param string[] $subadmin Groups where the user is subadmin + * @param list<string> $groups Groups of the user + * @param list<string> $subadmin Groups where the user is subadmin * @param string $quota Quota of the user * @param string $language Language of the user * @param ?string $manager Manager of the user @@ -689,7 +689,7 @@ class UsersController extends AUserData { * * Get a list of fields that are editable for the current user * - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: Editable fields returned @@ -710,7 +710,7 @@ class UsersController extends AUserData { * Get a list of fields that are editable for a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: Editable fields for user returned @@ -779,7 +779,7 @@ class UsersController extends AUserData { * @param string $collectionName Collection to update * @param string $key Key that will be updated * @param string $value New value for the key - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User values edited successfully @@ -884,7 +884,7 @@ class UsersController extends AUserData { * @param string $userId ID of the user * @param string $key Key that will be updated * @param string $value New value for the key - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User value edited successfully @@ -1222,7 +1222,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * * @throws OCSException * @@ -1261,7 +1261,7 @@ class UsersController extends AUserData { * Delete a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User deleted successfully @@ -1301,7 +1301,7 @@ class UsersController extends AUserData { * Disable a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User disabled successfully @@ -1316,7 +1316,7 @@ class UsersController extends AUserData { * Enable a user * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User enabled successfully @@ -1330,7 +1330,7 @@ class UsersController extends AUserData { /** * @param string $userId * @param bool $value - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException */ private function setEnabled(string $userId, bool $value): DataResponse { @@ -1360,7 +1360,7 @@ class UsersController extends AUserData { * Get a list of groups the user belongs to * * @param string $userId ID of the user - * @return DataResponse<Http::STATUS_OK, array{groups: string[]}, array{}> + * @return DataResponse<Http::STATUS_OK, array{groups: list<string>}, array{}> * @throws OCSException * * 200: Users groups returned @@ -1387,16 +1387,10 @@ class UsersController extends AUserData { // Looking up someone else if ($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) { // Return the group that the method caller is subadmin of for the user in question - /** @var IGroup[] $getSubAdminsGroups */ - $getSubAdminsGroups = $subAdminManager->getSubAdminsGroups($loggedInUser); - foreach ($getSubAdminsGroups as $key => $group) { - $getSubAdminsGroups[$key] = $group->getGID(); - } - /** @var string[] $groups */ - $groups = array_intersect( - $getSubAdminsGroups, + $groups = array_values(array_intersect( + array_map(static fn (IGroup $group) => $group->getGID(), $subAdminManager->getSubAdminsGroups($loggedInUser)), $this->groupManager->getUserGroupIds($targetUser) - ); + )); return new DataResponse(['groups' => $groups]); } else { // Not permitted @@ -1410,7 +1404,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User added to group successfully @@ -1450,7 +1444,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User removed from group successfully @@ -1517,7 +1511,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User added as group subadmin successfully @@ -1557,7 +1551,7 @@ class UsersController extends AUserData { * * @param string $userId ID of the user * @param string $groupid ID of the group - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: User removed as group subadmin successfully @@ -1591,7 +1585,7 @@ class UsersController extends AUserData { * Get the groups a user is a subadmin of * * @param string $userId ID if the user - * @return DataResponse<Http::STATUS_OK, string[], array{}> + * @return DataResponse<Http::STATUS_OK, list<string>, array{}> * @throws OCSException * * 200: User subadmin groups returned @@ -1606,7 +1600,7 @@ class UsersController extends AUserData { * Resend the welcome message * * @param string $userId ID if the user - * @return DataResponse<Http::STATUS_OK, array<empty>, array{}> + * @return DataResponse<Http::STATUS_OK, list<empty>, array{}> * @throws OCSException * * 200: Resent welcome message successfully |