@@ -267,16 +267,20 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA
267267 */
268268 #[AuthorizedAdminSetting(settings:Users::class)]
269269 public function setPreference (string $ key , string $ value ): JSONResponse {
270- if ( in_array ( $ key, [ ' newUser.sendEmail ' , ' group.sortBy ' ], true ) ) {
271- if ( $ key === 'newUser.sendEmail ' ) {
270+ switch ( $ key ) {
271+ case 'newUser.sendEmail ' :
272272 $ this ->appConfig ->setValueBool ('core ' , $ key , $ value === 'yes ' );
273- } else {
273+ break ;
274+ case 'group.sortBy ' :
274275 $ this ->appConfig ->setValueString ('core ' , $ key , $ value );
275- }
276- } elseif (in_array ($ key , self ::ALLOWED_USER_PREFERENCES , true )) {
277- $ this ->userConfig ->setValueBool ($ this ->userSession ->getUser ()->getUID (), $ this ->appName , $ key , $ value === 'true ' );
278- } else {
279- return new JSONResponse ([], Http::STATUS_FORBIDDEN );
276+ break ;
277+ default :
278+ if (in_array ($ key , self ::ALLOWED_USER_PREFERENCES , true )) {
279+ $ this ->userConfig ->setValueBool ($ this ->userSession ->getUser ()->getUID (), $ this ->appName , $ key , $ value === 'true ' );
280+ } else {
281+ return new JSONResponse ([], Http::STATUS_FORBIDDEN );
282+ }
283+ break ;
280284 }
281285
282286 return new JSONResponse ([]);
0 commit comments