4141use OCP \Encryption \IManager ;
4242use OCP \EventDispatcher \IEventDispatcher ;
4343use OCP \Group \ISubAdmin ;
44+ use OCP \IAppConfig ;
4445use OCP \IConfig ;
4546use OCP \IGroup ;
4647use OCP \IGroupManager ;
48+ use OCP \Config \IUserConfig ;
4749use OCP \IL10N ;
4850use OCP \INavigationManager ;
4951use OCP \IRequest ;
@@ -75,6 +77,8 @@ public function __construct(
7577 private IGroupManager $ groupManager ,
7678 private IUserSession $ userSession ,
7779 private IConfig $ config ,
80+ private IAppConfig $ appConfig ,
81+ private IUserConfig $ userConfig ,
7882 private IL10N $ l10n ,
7983 private IMailer $ mailer ,
8084 private IFactory $ l10nFactory ,
@@ -200,12 +204,12 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA
200204 }
201205
202206 /* QUOTAS PRESETS */
203- $ quotaPreset = $ this ->parseQuotaPreset ($ this ->config -> getAppValue ('files ' , 'quota_preset ' , '1 GB, 5 GB, 10 GB ' ));
204- $ allowUnlimitedQuota = $ this ->config -> getAppValue ('files ' , 'allow_unlimited_quota ' , ' 1 ' ) === ' 1 ' ;
207+ $ quotaPreset = $ this ->parseQuotaPreset ($ this ->appConfig -> getValueString ('files ' , 'quota_preset ' , '1 GB, 5 GB, 10 GB ' ));
208+ $ allowUnlimitedQuota = $ this ->appConfig -> getValueBool ('files ' , 'allow_unlimited_quota ' , true ) ;
205209 if (!$ allowUnlimitedQuota && count ($ quotaPreset ) > 0 ) {
206- $ defaultQuota = $ this ->config -> getAppValue ('files ' , 'default_quota ' , $ quotaPreset [0 ]);
210+ $ defaultQuota = $ this ->appConfig -> getValueString ('files ' , 'default_quota ' , $ quotaPreset [0 ]);
207211 } else {
208- $ defaultQuota = $ this ->config -> getAppValue ('files ' , 'default_quota ' , 'none ' );
212+ $ defaultQuota = $ this ->appConfig -> getValueString ('files ' , 'default_quota ' , 'none ' );
209213 }
210214
211215 $ event = new BeforeTemplateRenderedEvent ();
@@ -228,7 +232,7 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA
228232 $ serverData ['isDelegatedAdmin ' ] = $ isDelegatedAdmin ;
229233 $ serverData ['sortGroups ' ] = $ forceSortGroupByName
230234 ? MetaData::SORT_GROUPNAME
231- : (int )$ this ->config -> getAppValue ('core ' , 'group.sortBy ' , (string )MetaData::SORT_USERCOUNT );
235+ : (int )$ this ->appConfig -> getValueString ('core ' , 'group.sortBy ' , (string )MetaData::SORT_USERCOUNT );
232236 $ serverData ['forceSortGroupByName ' ] = $ forceSortGroupByName ;
233237 $ serverData ['quotaPreset ' ] = $ quotaPreset ;
234238 $ serverData ['allowUnlimitedQuota ' ] = $ allowUnlimitedQuota ;
@@ -239,12 +243,12 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA
239243 // Settings
240244 $ serverData ['defaultQuota ' ] = $ defaultQuota ;
241245 $ serverData ['canChangePassword ' ] = $ canChangePassword ;
242- $ serverData ['newUserGenerateUserID ' ] = $ this ->config -> getAppValue ('core ' , 'newUser.generateUserID ' , ' no ' ) === ' yes ' ;
243- $ serverData ['newUserRequireEmail ' ] = $ this ->config -> getAppValue ('core ' , 'newUser.requireEmail ' , ' no ' ) === ' yes ' ;
244- $ serverData ['newUserSendEmail ' ] = $ this ->config -> getAppValue ('core ' , 'newUser.sendEmail ' , ' yes ' ) === ' yes ' ;
246+ $ serverData ['newUserGenerateUserID ' ] = $ this ->appConfig -> getValueBool ('core ' , 'newUser.generateUserID ' , false ) ;
247+ $ serverData ['newUserRequireEmail ' ] = $ this ->appConfig -> getValueBool ('core ' , 'newUser.requireEmail ' , false ) ;
248+ $ serverData ['newUserSendEmail ' ] = $ this ->appConfig -> getValueBool ('core ' , 'newUser.sendEmail ' , true ) ;
245249 $ serverData ['showConfig ' ] = [];
246250 foreach (self ::ALLOWED_USER_PREFERENCES as $ key ) {
247- $ serverData ['showConfig ' ][$ key ] = $ this ->config -> getUserValue ($ uid , $ this ->appName , $ key , ' false ' ) === ' true ' ;
251+ $ serverData ['showConfig ' ][$ key ] = $ this ->userConfig -> getValueBool ($ uid , $ this ->appName , $ key , false ) ;
248252 }
249253
250254 $ this ->initialState ->provideInitialState ('usersSettings ' , $ serverData );
@@ -263,12 +267,19 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA
263267 */
264268 #[AuthorizedAdminSetting(settings:Users::class)]
265269 public function setPreference (string $ key , string $ value ): JSONResponse {
266- $ allowedAppValues = ['newUser.sendEmail ' , 'group.sortBy ' ];
270+ $ allowedAppValues = [
271+ 'newUser.sendEmail ' ,
272+ 'group.sortBy ' ,
273+ ];
267274
268275 if (in_array ($ key , $ allowedAppValues , true )) {
269- $ this ->config ->setAppValue ('core ' , $ key , $ value );
276+ if ($ key === 'newUser.sendEmail ' ) {
277+ $ this ->appConfig ->setValueBool ('core ' , $ key , $ value === 'yes ' );
278+ } else {
279+ $ this ->appConfig ->setValueString ('core ' , $ key , $ value );
280+ }
270281 } elseif (in_array ($ key , self ::ALLOWED_USER_PREFERENCES , true )) {
271- $ this ->config -> setUserValue ($ this ->userSession ->getUser ()->getUID (), $ this ->appName , $ key , $ value );
282+ $ this ->userConfig -> setValueBool ($ this ->userSession ->getUser ()->getUID (), $ this ->appName , $ key , $ value === ' true ' );
272283 } else {
273284 return new JSONResponse ([], Http::STATUS_FORBIDDEN );
274285 }
0 commit comments