2828use OCP \Capabilities \ICapability ;
2929use OCP \Constants ;
3030use OCP \IConfig ;
31+ use OCP \Share \IManager ;
3132
3233/**
3334 * Class Capabilities
@@ -38,9 +39,12 @@ class Capabilities implements ICapability {
3839
3940 /** @var IConfig */
4041 private $ config ;
42+ /** @var IManager */
43+ private $ shareManager ;
4144
42- public function __construct (IConfig $ config ) {
45+ public function __construct (IConfig $ config, IManager $ shareManager ) {
4346 $ this ->config = $ config ;
47+ $ this ->shareManager = $ shareManager ;
4448 }
4549
4650 /**
@@ -51,7 +55,7 @@ public function __construct(IConfig $config) {
5155 public function getCapabilities () {
5256 $ res = [];
5357
54- if ($ this ->config -> getAppValue ( ' core ' , ' shareapi_enabled ' , ' yes ' ) !== ' yes ' ) {
58+ if (! $ this ->shareManager -> shareApiEnabled () ) {
5559 $ res ['api_enabled ' ] = false ;
5660 $ res ['public ' ] = ['enabled ' => false ];
5761 $ res ['user ' ] = ['send_mail ' => false ];
@@ -60,10 +64,10 @@ public function getCapabilities() {
6064 $ res ['api_enabled ' ] = true ;
6165
6266 $ public = [];
63- $ public ['enabled ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_allow_links ' , ' yes ' ) === ' yes ' ;
67+ $ public ['enabled ' ] = $ this ->shareManager -> shareApiAllowLinks () ;
6468 if ($ public ['enabled ' ]) {
6569 $ public ['password ' ] = [];
66- $ public ['password ' ]['enforced ' ] = ( $ this ->config -> getAppValue ( ' core ' , ' shareapi_enforce_links_password ' , ' no ' ) === ' yes ' );
70+ $ public ['password ' ]['enforced ' ] = $ this ->shareManager -> shareApiLinkEnforcePassword ( );
6771
6872 if ($ public ['password ' ]['enforced ' ]) {
6973 $ public ['password ' ]['askForOptionalPassword ' ] = false ;
@@ -73,28 +77,28 @@ public function getCapabilities() {
7377
7478 $ public ['expire_date ' ] = [];
7579 $ public ['multiple_links ' ] = true ;
76- $ public ['expire_date ' ]['enabled ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_default_expire_date ' , ' no ' ) === ' yes ' ;
80+ $ public ['expire_date ' ]['enabled ' ] = $ this ->shareManager -> shareApiLinkDefaultExpireDate () ;
7781 if ($ public ['expire_date ' ]['enabled ' ]) {
78- $ public ['expire_date ' ]['days ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_expire_after_n_days ' , ' 7 ' );
79- $ public ['expire_date ' ]['enforced ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_enforce_expire_date ' , ' no ' ) === ' yes ' ;
82+ $ public ['expire_date ' ]['days ' ] = $ this ->shareManager -> shareApiLinkDefaultExpireDays ( );
83+ $ public ['expire_date ' ]['enforced ' ] = $ this ->shareManager -> shareApiLinkDefaultExpireDateEnforced () ;
8084 }
8185
8286 $ public ['expire_date_internal ' ] = [];
83- $ public ['expire_date_internal ' ]['enabled ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_default_internal_expire_date ' , ' no ' ) === ' yes ' ;
87+ $ public ['expire_date_internal ' ]['enabled ' ] = $ this ->shareManager -> shareApiInternalDefaultExpireDate () ;
8488 if ($ public ['expire_date_internal ' ]['enabled ' ]) {
85- $ public ['expire_date_internal ' ]['days ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_internal_expire_after_n_days ' , ' 7 ' );
86- $ public ['expire_date_internal ' ]['enforced ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_enforce_internal_expire_date ' , ' no ' ) === ' yes ' ;
89+ $ public ['expire_date_internal ' ]['days ' ] = $ this ->shareManager -> shareApiInternalDefaultExpireDays ( );
90+ $ public ['expire_date_internal ' ]['enforced ' ] = $ this ->shareManager -> shareApiInternalDefaultExpireDateEnforced () ;
8791 }
8892
8993 $ public ['expire_date_remote ' ] = [];
90- $ public ['expire_date_remote ' ]['enabled ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_default_remote_expire_date ' , ' no ' ) === ' yes ' ;
94+ $ public ['expire_date_remote ' ]['enabled ' ] = $ this ->shareManager -> shareApiRemoteDefaultExpireDate () ;
9195 if ($ public ['expire_date_remote ' ]['enabled ' ]) {
92- $ public ['expire_date_remote ' ]['days ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_remote_expire_after_n_days ' , ' 7 ' );
93- $ public ['expire_date_remote ' ]['enforced ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_enforce_remote_expire_date ' , ' no ' ) === ' yes ' ;
96+ $ public ['expire_date_remote ' ]['days ' ] = $ this ->shareManager -> shareApiRemoteDefaultExpireDays ( );
97+ $ public ['expire_date_remote ' ]['enforced ' ] = $ this ->shareManager -> shareApiRemoteDefaultExpireDateEnforced () ;
9498 }
9599
96100 $ public ['send_mail ' ] = $ this ->config ->getAppValue ('core ' , 'shareapi_allow_public_notification ' , 'no ' ) === 'yes ' ;
97- $ public ['upload ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_allow_public_upload ' , ' yes ' ) === ' yes ' ;
101+ $ public ['upload ' ] = $ this ->shareManager -> shareApiLinkAllowPublicUpload () ;
98102 $ public ['upload_files_drop ' ] = $ public ['upload ' ];
99103 }
100104 $ res ['public ' ] = $ public ;
@@ -106,17 +110,17 @@ public function getCapabilities() {
106110
107111 // deprecated in favour of 'group', but we need to keep it for now
108112 // in order to stay compatible with older clients
109- $ res ['group_sharing ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_allow_group_sharing ' , ' yes ' ) === ' yes ' ;
113+ $ res ['group_sharing ' ] = $ this ->shareManager -> allowGroupSharing () ;
110114
111115 $ res ['group ' ] = [];
112- $ res ['group ' ]['enabled ' ] = $ this ->config -> getAppValue ( ' core ' , ' shareapi_allow_group_sharing ' , ' yes ' ) === ' yes ' ;
116+ $ res ['group ' ]['enabled ' ] = $ this ->shareManager -> allowGroupSharing () ;
113117 $ res ['group ' ]['expire_date ' ]['enabled ' ] = true ;
114118 $ res ['default_permissions ' ] = (int )$ this ->config ->getAppValue ('core ' , 'shareapi_default_permissions ' , Constants::PERMISSION_ALL );
115119 }
116120
117121 //Federated sharing
118122 $ res ['federation ' ] = [
119- 'outgoing ' => $ this ->config -> getAppValue ( ' files_sharing ' , ' outgoing_server2server_share_enabled ' , ' yes ' ) === ' yes ' ,
123+ 'outgoing ' => $ this ->shareManager -> outgoingServer2ServerSharesAllowed () ,
120124 'incoming ' => $ this ->config ->getAppValue ('files_sharing ' , 'incoming_server2server_share_enabled ' , 'yes ' ) === 'yes ' ,
121125 // old bogus one, expire_date was not working before, keeping for compatibility
122126 'expire_date ' => ['enabled ' => true ],
0 commit comments