5858 * @psalm-import-type Provisioning_APIGroupDetails from ResponseDefinitions
5959 * @psalm-import-type Provisioning_APIUserDetails from ResponseDefinitions
6060 */
61- class UsersController extends AUserDataOCSController
62- {
61+ class UsersController extends AUserDataOCSController {
6362
6463 private IL10N $ l10n ;
6564
@@ -112,8 +111,7 @@ public function __construct(
112111 * 200: Users returned
113112 */
114113 #[NoAdminRequired]
115- public function getUsers (string $ search = '' , ?int $ limit = null , int $ offset = 0 ): DataResponse
116- {
114+ public function getUsers (string $ search = '' , ?int $ limit = null , int $ offset = 0 ): DataResponse {
117115 $ user = $ this ->userSession ->getUser ();
118116 $ users = [];
119117
@@ -155,8 +153,7 @@ public function getUsers(string $search = '', ?int $limit = null, int $offset =
155153 * 200: Users details returned
156154 */
157155 #[NoAdminRequired]
158- public function getUsersDetails (string $ search = '' , ?int $ limit = null , int $ offset = 0 ): DataResponse
159- {
156+ public function getUsersDetails (string $ search = '' , ?int $ limit = null , int $ offset = 0 ): DataResponse {
160157 $ currentUser = $ this ->userSession ->getUser ();
161158 $ users = [];
162159
@@ -183,7 +180,7 @@ public function getUsersDetails(string $search = '', ?int $limit = null, int $of
183180
184181 $ usersDetails = [];
185182 foreach ($ users as $ userId ) {
186- $ userId = (string ) $ userId ;
183+ $ userId = (string )$ userId ;
187184 try {
188185 $ userData = $ this ->getUserData ($ userId );
189186 } catch (OCSNotFoundException $ e ) {
@@ -218,8 +215,7 @@ public function getUsersDetails(string $search = '', ?int $limit = null, int $of
218215 * 200: Disabled users details returned
219216 */
220217 #[NoAdminRequired]
221- public function getDisabledUsersDetails (string $ search = '' , ?int $ limit = null , int $ offset = 0 ): DataResponse
222- {
218+ public function getDisabledUsersDetails (string $ search = '' , ?int $ limit = null , int $ offset = 0 ): DataResponse {
223219 $ currentUser = $ this ->userSession ->getUser ();
224220 if ($ currentUser === null ) {
225221 return new DataResponse (['users ' => []]);
@@ -240,7 +236,7 @@ public function getDisabledUsersDetails(string $search = '', ?int $limit = null,
240236 $ isDelegatedAdmin = $ this ->groupManager ->isDelegatedAdmin ($ uid );
241237 if ($ isAdmin || $ isDelegatedAdmin ) {
242238 $ users = $ this ->userManager ->getDisabledUsers ($ limit , $ offset , $ search );
243- $ users = array_map (fn (IUser $ user ): string => $ user ->getUID (), $ users );
239+ $ users = array_map (fn (IUser $ user ): string => $ user ->getUID (), $ users );
244240 } elseif ($ subAdminManager ->isSubAdmin ($ currentUser )) {
245241 $ subAdminOfGroups = $ subAdminManager ->getSubAdminsGroups ($ currentUser );
246242
@@ -251,10 +247,10 @@ public function getDisabledUsersDetails(string $search = '', ?int $limit = null,
251247 $ users = array_unique (array_merge (
252248 $ users ,
253249 array_map (
254- fn (IUser $ user ): string => $ user ->getUID (),
250+ fn (IUser $ user ): string => $ user ->getUID (),
255251 array_filter (
256252 $ group ->searchUsers ($ search ),
257- fn (IUser $ user ): bool => !$ user ->isEnabled ()
253+ fn (IUser $ user ): bool => !$ user ->isEnabled ()
258254 )
259255 )
260256 ));
@@ -362,8 +358,7 @@ public function getLastLoggedInUsers(
362358 * 400: Invalid location
363359 */
364360 #[NoAdminRequired]
365- public function searchByPhoneNumbers (string $ location , array $ search ): DataResponse
366- {
361+ public function searchByPhoneNumbers (string $ location , array $ search ): DataResponse {
367362 if ($ this ->phoneNumberUtil ->getCountryCodeForRegion ($ location ) === null ) {
368363 // Not a valid region code
369364 return new DataResponse ([], Http::STATUS_BAD_REQUEST );
@@ -379,7 +374,7 @@ public function searchByPhoneNumbers(string $location, array $search): DataRespo
379374 foreach ($ phoneNumbers as $ phone ) {
380375 $ normalizedNumber = $ this ->phoneNumberUtil ->convertToStandardFormat ($ phone , $ location );
381376 if ($ normalizedNumber !== null ) {
382- $ normalizedNumberToKey [$ normalizedNumber ] = (string ) $ key ;
377+ $ normalizedNumberToKey [$ normalizedNumber ] = (string )$ key ;
383378 }
384379
385380 if ($ defaultPhoneRegion !== '' && $ defaultPhoneRegion !== $ location && str_starts_with ($ phone , '0 ' )) {
@@ -388,7 +383,7 @@ public function searchByPhoneNumbers(string $location, array $search): DataRespo
388383 // when it's different to the user's given region.
389384 $ normalizedNumber = $ this ->phoneNumberUtil ->convertToStandardFormat ($ phone , $ defaultPhoneRegion );
390385 if ($ normalizedNumber !== null ) {
391- $ normalizedNumberToKey [$ normalizedNumber ] = (string ) $ key ;
386+ $ normalizedNumberToKey [$ normalizedNumber ] = (string )$ key ;
392387 }
393388 }
394389 }
@@ -429,8 +424,7 @@ public function searchByPhoneNumbers(string $location, array $search): DataRespo
429424 /**
430425 * @throws OCSException
431426 */
432- private function createNewUserId (): string
433- {
427+ private function createNewUserId (): string {
434428 $ attempts = 0 ;
435429 do {
436430 $ uidCandidate = $ this ->secureRandom ->generate (10 , ISecureRandom::CHAR_HUMAN_READABLE );
@@ -670,8 +664,7 @@ public function addUser(
670664 * 200: User returned
671665 */
672666 #[NoAdminRequired]
673- public function getUser (string $ userId ): DataResponse
674- {
667+ public function getUser (string $ userId ): DataResponse {
675668 $ includeScopes = false ;
676669 $ currentUser = $ this ->userSession ->getUser ();
677670 if ($ currentUser && $ currentUser ->getUID () === $ userId ) {
@@ -697,8 +690,7 @@ public function getUser(string $userId): DataResponse
697690 * 200: Current user returned
698691 */
699692 #[NoAdminRequired]
700- public function getCurrentUser (): DataResponse
701- {
693+ public function getCurrentUser (): DataResponse {
702694 $ user = $ this ->userSession ->getUser ();
703695 if ($ user ) {
704696 /** @var Provisioning_APIUserDetails $data */
@@ -720,8 +712,7 @@ public function getCurrentUser(): DataResponse
720712 * 200: Editable fields returned
721713 */
722714 #[NoAdminRequired]
723- public function getEditableFields (): DataResponse
724- {
715+ public function getEditableFields (): DataResponse {
725716 $ currentLoggedInUser = $ this ->userSession ->getUser ();
726717 if (!$ currentLoggedInUser instanceof IUser) {
727718 throw new OCSException ('' , OCSController::RESPOND_NOT_FOUND );
@@ -738,8 +729,7 @@ public function getEditableFields(): DataResponse
738729 * 200: Enabled apps returned
739730 */
740731 #[NoAdminRequired]
741- public function getEnabledApps (): DataResponse
742- {
732+ public function getEnabledApps (): DataResponse {
743733 $ currentLoggedInUser = $ this ->userSession ->getUser ();
744734 return new DataResponse (['apps ' => $ this ->appManager ->getEnabledAppsForUser ($ currentLoggedInUser )]);
745735 }
@@ -756,8 +746,7 @@ public function getEnabledApps(): DataResponse
756746 * 200: Editable fields for user returned
757747 */
758748 #[NoAdminRequired]
759- public function getEditableFieldsForUser (string $ userId ): DataResponse
760- {
749+ public function getEditableFieldsForUser (string $ userId ): DataResponse {
761750 $ currentLoggedInUser = $ this ->userSession ->getUser ();
762751 if (!$ currentLoggedInUser instanceof IUser) {
763752 throw new OCSException ('' , OCSController::RESPOND_NOT_FOUND );
@@ -1013,7 +1002,7 @@ public function editUserMultiField(
10131002 $ errors ['quota ' ] = $ this ->l10n ->t ('Insufficient permissions to change quota ' );
10141003 } elseif ($ quota !== 'none ' && $ quota !== 'default ' ) {
10151004 if (is_numeric ($ quota )) {
1016- $ quota = (float ) $ quota ;
1005+ $ quota = (float )$ quota ;
10171006 } else {
10181007 $ quota = Util::computerFileSize ($ quota );
10191008 }
@@ -1106,7 +1095,7 @@ public function editUserMultiField(
11061095
11071096 if ($ groups !== null && ($ isAdmin || $ isDelegatedAdmin )) {
11081097 $ currentGroups = $ this ->groupManager ->getUserGroups ($ targetUser );
1109- $ currentGroupIds = array_map (fn (IGroup $ g ) => $ g ->getGID (), $ currentGroups );
1098+ $ currentGroupIds = array_map (fn (IGroup $ g ) => $ g ->getGID (), $ currentGroups );
11101099 foreach (array_diff ($ currentGroupIds , $ groups ) as $ gid ) {
11111100 $ this ->groupManager ->get ($ gid )?->removeUser($ targetUser );
11121101 }
@@ -1125,7 +1114,7 @@ public function editUserMultiField(
11251114
11261115 if ($ subadminGroups !== null && ($ isAdmin || $ isDelegatedAdmin )) {
11271116 $ currentSubAdminGroups = $ subAdminManager ->getSubAdminsGroups ($ targetUser );
1128- $ currentSubAdminGroupIds = array_map (fn (IGroup $ g ) => $ g ->getGID (), $ currentSubAdminGroups );
1117+ $ currentSubAdminGroupIds = array_map (fn (IGroup $ g ) => $ g ->getGID (), $ currentSubAdminGroups );
11291118 foreach (array_diff ($ currentSubAdminGroupIds , $ subadminGroups ) as $ gid ) {
11301119 $ group = $ this ->groupManager ->get ($ gid );
11311120 if ($ group !== null ) {
@@ -1163,8 +1152,7 @@ public function editUserMultiField(
11631152 #[PasswordConfirmationRequired]
11641153 #[NoAdminRequired]
11651154 #[UserRateLimit(limit: 50 , period: 600 )]
1166- public function editUser (string $ userId , string $ key , string $ value ): DataResponse
1167- {
1155+ public function editUser (string $ userId , string $ key , string $ value ): DataResponse {
11681156 $ currentLoggedInUser = $ this ->userSession ->getUser ();
11691157
11701158 $ targetUser = $ this ->userManager ->get ($ userId );
@@ -1279,7 +1267,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
12791267 $ quota = $ value ;
12801268 if ($ quota !== 'none ' && $ quota !== 'default ' ) {
12811269 if (is_numeric ($ quota )) {
1282- $ quota = (float ) $ quota ;
1270+ $ quota = (float )$ quota ;
12831271 } else {
12841272 $ quota = Util::computerFileSize ($ quota );
12851273 }
@@ -1289,7 +1277,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
12891277 if ($ quota === -1 ) {
12901278 $ quota = 'none ' ;
12911279 } else {
1292- $ maxQuota = (int ) $ this ->config ->getAppValue ('files ' , 'max_quota ' , '-1 ' );
1280+ $ maxQuota = (int )$ this ->config ->getAppValue ('files ' , 'max_quota ' , '-1 ' );
12931281 if ($ maxQuota !== -1 && $ quota > $ maxQuota ) {
12941282 throw new OCSException ($ this ->l10n ->t ('Invalid quota value. %1$s is exceeding the maximum quota ' , [$ value ]), 101 );
12951283 }
@@ -1341,7 +1329,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
13411329 $ this ->config ->setUserValue ($ targetUser ->getUID (), 'core ' , 'timezone ' , $ value );
13421330 break ;
13431331 case self ::USER_FIELD_FIRST_DAY_OF_WEEK :
1344- $ intValue = (int ) $ value ;
1332+ $ intValue = (int )$ value ;
13451333 if ($ intValue < -1 || $ intValue > 6 ) {
13461334 throw new OCSException ($ this ->l10n ->t ('Invalid first day of week ' ), 101 );
13471335 }
@@ -1488,8 +1476,7 @@ public function editUser(string $userId, string $key, string $value): DataRespon
14881476 */
14891477 #[PasswordConfirmationRequired]
14901478 #[NoAdminRequired]
1491- public function wipeUserDevices (string $ userId ): DataResponse
1492- {
1479+ public function wipeUserDevices (string $ userId ): DataResponse {
14931480 /** @var IUser $currentLoggedInUser */
14941481 $ currentLoggedInUser = $ this ->userSession ->getUser ();
14951482
@@ -1527,8 +1514,7 @@ public function wipeUserDevices(string $userId): DataResponse
15271514 */
15281515 #[PasswordConfirmationRequired]
15291516 #[NoAdminRequired]
1530- public function deleteUser (string $ userId ): DataResponse
1531- {
1517+ public function deleteUser (string $ userId ): DataResponse {
15321518 $ currentLoggedInUser = $ this ->userSession ->getUser ();
15331519
15341520 $ targetUser = $ this ->userManager ->get ($ userId );
@@ -1568,8 +1554,7 @@ public function deleteUser(string $userId): DataResponse
15681554 */
15691555 #[PasswordConfirmationRequired]
15701556 #[NoAdminRequired]
1571- public function disableUser (string $ userId ): DataResponse
1572- {
1557+ public function disableUser (string $ userId ): DataResponse {
15731558 return $ this ->setEnabled ($ userId , false );
15741559 }
15751560
@@ -1584,8 +1569,7 @@ public function disableUser(string $userId): DataResponse
15841569 */
15851570 #[PasswordConfirmationRequired]
15861571 #[NoAdminRequired]
1587- public function enableUser (string $ userId ): DataResponse
1588- {
1572+ public function enableUser (string $ userId ): DataResponse {
15891573 return $ this ->setEnabled ($ userId , true );
15901574 }
15911575
@@ -1595,8 +1579,7 @@ public function enableUser(string $userId): DataResponse
15951579 * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
15961580 * @throws OCSException
15971581 */
1598- private function setEnabled (string $ userId , bool $ value ): DataResponse
1599- {
1582+ private function setEnabled (string $ userId , bool $ value ): DataResponse {
16001583 $ currentLoggedInUser = $ this ->userSession ->getUser ();
16011584
16021585 $ targetUser = $ this ->userManager ->get ($ userId );
@@ -1629,8 +1612,7 @@ private function setEnabled(string $userId, bool $value): DataResponse
16291612 * 200: Users groups returned
16301613 */
16311614 #[NoAdminRequired]
1632- public function getUsersGroups (string $ userId ): DataResponse
1633- {
1615+ public function getUsersGroups (string $ userId ): DataResponse {
16341616 $ loggedInUser = $ this ->userSession ->getUser ();
16351617
16361618 $ targetUser = $ this ->userManager ->get ($ userId );
@@ -1652,7 +1634,7 @@ public function getUsersGroups(string $userId): DataResponse
16521634 if ($ subAdminManager ->isUserAccessible ($ loggedInUser , $ targetUser )) {
16531635 // Return the group that the method caller is subadmin of for the user in question
16541636 $ groups = array_values (array_intersect (
1655- array_map (static fn (IGroup $ group ) => $ group ->getGID (), $ subAdminManager ->getSubAdminsGroups ($ loggedInUser )),
1637+ array_map (static fn (IGroup $ group ) => $ group ->getGID (), $ subAdminManager ->getSubAdminsGroups ($ loggedInUser )),
16561638 $ this ->groupManager ->getUserGroupIds ($ targetUser )
16571639 ));
16581640 return new DataResponse (['groups ' => $ groups ]);
@@ -1675,8 +1657,7 @@ public function getUsersGroups(string $userId): DataResponse
16751657 * 200: Users groups returned
16761658 */
16771659 #[NoAdminRequired]
1678- public function getUsersGroupsDetails (string $ userId ): DataResponse
1679- {
1660+ public function getUsersGroupsDetails (string $ userId ): DataResponse {
16801661 $ loggedInUser = $ this ->userSession ->getUser ();
16811662
16821663 $ targetUser = $ this ->userManager ->get ($ userId );
@@ -1712,7 +1693,7 @@ function (Group $group) {
17121693 // Return the group that the method caller is subadmin of for the user in question
17131694 $ gids = array_values (array_intersect (
17141695 array_map (
1715- static fn (IGroup $ group ) => $ group ->getGID (),
1696+ static fn (IGroup $ group ) => $ group ->getGID (),
17161697 $ subAdminManager ->getSubAdminsGroups ($ loggedInUser ),
17171698 ),
17181699 $ this ->groupManager ->getUserGroupIds ($ targetUser )
@@ -1753,8 +1734,7 @@ function (string $gid) {
17531734 * 200: Users subadmin groups returned
17541735 */
17551736 #[NoAdminRequired]
1756- public function getUserSubAdminGroupsDetails (string $ userId ): DataResponse
1757- {
1737+ public function getUserSubAdminGroupsDetails (string $ userId ): DataResponse {
17581738 $ loggedInUser = $ this ->userSession ->getUser ();
17591739
17601740 $ targetUser = $ this ->userManager ->get ($ userId );
@@ -1798,8 +1778,7 @@ function (IGroup $group) {
17981778 */
17991779 #[PasswordConfirmationRequired]
18001780 #[NoAdminRequired]
1801- public function addToGroup (string $ userId , string $ groupid = '' ): DataResponse
1802- {
1781+ public function addToGroup (string $ userId , string $ groupid = '' ): DataResponse {
18031782 if ($ groupid === '' ) {
18041783 throw new OCSException ('' , 101 );
18051784 }
@@ -1839,8 +1818,7 @@ public function addToGroup(string $userId, string $groupid = ''): DataResponse
18391818 */
18401819 #[PasswordConfirmationRequired]
18411820 #[NoAdminRequired]
1842- public function removeFromGroup (string $ userId , string $ groupid ): DataResponse
1843- {
1821+ public function removeFromGroup (string $ userId , string $ groupid ): DataResponse {
18441822 $ loggedInUser = $ this ->userSession ->getUser ();
18451823
18461824 if ($ groupid === null || trim ($ groupid ) === '' ) {
@@ -1907,8 +1885,7 @@ public function removeFromGroup(string $userId, string $groupid): DataResponse
19071885 */
19081886 #[AuthorizedAdminSetting(settings: Users::class)]
19091887 #[PasswordConfirmationRequired]
1910- public function addSubAdmin (string $ userId , string $ groupid ): DataResponse
1911- {
1888+ public function addSubAdmin (string $ userId , string $ groupid ): DataResponse {
19121889 $ group = $ this ->groupManager ->get ($ groupid );
19131890 $ user = $ this ->userManager ->get ($ userId );
19141891
@@ -1948,8 +1925,7 @@ public function addSubAdmin(string $userId, string $groupid): DataResponse
19481925 */
19491926 #[AuthorizedAdminSetting(settings: Users::class)]
19501927 #[PasswordConfirmationRequired]
1951- public function removeSubAdmin (string $ userId , string $ groupid ): DataResponse
1952- {
1928+ public function removeSubAdmin (string $ userId , string $ groupid ): DataResponse {
19531929 $ group = $ this ->groupManager ->get ($ groupid );
19541930 $ user = $ this ->userManager ->get ($ userId );
19551931 $ subAdminManager = $ this ->groupManager ->getSubAdmin ();
@@ -1982,8 +1958,7 @@ public function removeSubAdmin(string $userId, string $groupid): DataResponse
19821958 * 200: User subadmin groups returned
19831959 */
19841960 #[AuthorizedAdminSetting(settings: Users::class)]
1985- public function getUserSubAdminGroups (string $ userId ): DataResponse
1986- {
1961+ public function getUserSubAdminGroups (string $ userId ): DataResponse {
19871962 $ groups = $ this ->getUserSubAdminGroupsData ($ userId );
19881963 return new DataResponse ($ groups );
19891964 }
@@ -1999,8 +1974,7 @@ public function getUserSubAdminGroups(string $userId): DataResponse
19991974 */
20001975 #[PasswordConfirmationRequired]
20011976 #[NoAdminRequired]
2002- public function resendWelcomeMessage (string $ userId ): DataResponse
2003- {
1977+ public function resendWelcomeMessage (string $ userId ): DataResponse {
20041978 $ currentLoggedInUser = $ this ->userSession ->getUser ();
20051979
20061980 $ targetUser = $ this ->userManager ->get ($ userId );
0 commit comments