1111
1212use OCP \AppFramework \Services \IAppConfig ;
1313use OCP \Group \ISubAdmin ;
14+ use OCP \IAppConfig as IGlobalAppConfig ;
1415use OCP \IConfig ;
1516use OCP \IGroupManager ;
1617use OCP \IUserSession ;
1718
1819class Config {
1920 public function __construct (
2021 private readonly IConfig $ config ,
22+ private readonly IGlobalAppConfig $ globalAppConfig ,
2123 private readonly IAppConfig $ appConfig ,
2224 private readonly ISubAdmin $ subAdmin ,
2325 private readonly IUserSession $ userSession ,
@@ -26,11 +28,11 @@ public function __construct(
2628 }
2729
2830 public function allowExternalStorage (): bool {
29- return $ this ->appConfig ->getAppValueBool (' allow_external_storage ' , false );
31+ return $ this ->appConfig ->getAppValueBool (ConfigLexicon:: EXTERNAL_STORAGE_ENABLED );
3032 }
3133
32- public function setAllowExternalStorage (string | bool $ allow ): void {
33- $ this ->appConfig ->setAppValueBool (' allow_external_storage ' , $ allow === true || $ allow === ' true ' ) ;
34+ public function setAllowExternalStorage (bool $ allow ): void {
35+ $ this ->appConfig ->setAppValueBool (ConfigLexicon:: EXTERNAL_STORAGE_ENABLED , $ allow) ;
3436 }
3537
3638 public function useHashedEmailAsUserID (): bool {
@@ -42,43 +44,38 @@ public function setUseHashedEmailAsUserID(bool $useHash): void {
4244 }
4345
4446 public function hideOtherUsers (): bool {
45- return $ this ->appConfig ->getAppValueBool (' hide_users ' , true );
47+ return $ this ->appConfig ->getAppValueBool (ConfigLexicon:: HIDE_OTHER_ACCOUNTS );
4648 }
4749
48- public function setHideOtherUsers (string | bool $ hide ): void {
49- $ this ->appConfig ->setAppValueBool (' hide_users ' , $ hide === true || $ hide === ' true ' ) ;
50+ public function setHideOtherUsers (bool $ hide ): void {
51+ $ this ->appConfig ->setAppValueBool (ConfigLexicon:: HIDE_OTHER_ACCOUNTS , $ hide) ;
5052 }
5153
5254 public function getHome (string $ uid ): string {
5355 return $ this ->config ->getSystemValue ('datadirectory ' , \OC ::$ SERVERROOT . '/data ' ) . '/ ' . $ uid ;
5456 }
5557
5658 public function useWhitelist (): bool {
57- return $ this ->appConfig ->getAppValueBool (' usewhitelist ' , true );
59+ return $ this ->appConfig ->getAppValueBool (ConfigLexicon:: WHITE_LIST_ENABLED );
5860 }
5961
60- public function setUseWhitelist (string | bool $ use ): void {
61- $ this ->appConfig ->setAppValueBool (' usewhitelist ' , $ use === true || $ use === ' true ' ) ;
62+ public function setUseWhitelist (bool $ use ): void {
63+ $ this ->appConfig ->setAppValueBool (ConfigLexicon:: WHITE_LIST_ENABLED , $ use) ;
6264 }
6365
6466 /**
6567 * @return list<string>
6668 */
6769 public function getAppWhitelist (): array {
68- $ whitelist = $ this ->appConfig ->getAppValueString ('whitelist ' , AppWhitelist::DEFAULT_WHITELIST );
69- return explode (', ' , $ whitelist );
70+ return explode (', ' , $ this ->appConfig ->getAppValueString (ConfigLexicon::WHITE_LIST ));
7071 }
7172
72- public function setAppWhitelist (array |string $ whitelist ): void {
73- if (is_array ($ whitelist )) {
74- $ whitelist = implode (', ' , $ whitelist );
75- }
76-
77- $ this ->appConfig ->setAppValueString ('whitelist ' , $ whitelist );
73+ public function setAppWhitelist (array $ whitelist ): void {
74+ $ this ->appConfig ->setAppValueString (ConfigLexicon::WHITE_LIST , implode (', ' , $ whitelist ));
7875 }
7976
8077 public function isSharingRestrictedToGroup (): bool {
81- return $ this ->config -> getAppValue ('core ' , 'shareapi_only_share_with_group_members ' , ' no ' ) === ' yes ' ;
78+ return $ this ->globalAppConfig -> getValueBool ('core ' , 'shareapi_only_share_with_group_members ' ) ;
8279 }
8380
8481 public function canCreateGuests (): bool {
@@ -111,7 +108,7 @@ public function canCreateGuests(): bool {
111108 * @return list<string>
112109 */
113110 public function getCreateRestrictedToGroup (): array {
114- $ groups = $ this ->appConfig ->getAppValueArray (' create_restricted_to_group ' , [] );
111+ $ groups = $ this ->appConfig ->getAppValueArray (ConfigLexicon:: GROUP_LIMITATION );
115112 // If empty, it means there is no restriction
116113 if (empty ($ groups )) {
117114 return [];
@@ -120,7 +117,7 @@ public function getCreateRestrictedToGroup(): array {
120117 // It does not matter at this point if the admin
121118 // group is in the list or not. We are checking it
122119 // anyway in the canCreateGuests method.
123- return array_values (array_unique ($ this ->appConfig ->getAppValueArray (' create_restricted_to_group ' , [] )));
120+ return array_values (array_unique ($ this ->appConfig ->getAppValueArray (ConfigLexicon:: GROUP_LIMITATION )));
124121 }
125122
126123 /**
0 commit comments