1414use OCA \DAV \CardDAV \Integration \IAddressBookProvider ;
1515use OCA \Federation \TrustedServers ;
1616use OCP \AppFramework \QueryException ;
17+ use OCP \IAppConfig ;
1718use OCP \IConfig ;
1819use OCP \IGroupManager ;
1920use OCP \IL10N ;
2021use OCP \IRequest ;
2122use OCP \IUser ;
2223use OCP \IUserSession ;
2324use OCP \Server ;
25+ use OCP \Util ;
2426use Psr \Container \ContainerExceptionInterface ;
2527use Psr \Container \NotFoundExceptionInterface ;
2628use Sabre \CardDAV \Backend ;
@@ -36,6 +38,9 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
3638 /** @var IConfig */
3739 protected $ config ;
3840
41+ /** @var IAppConfig */
42+ protected $ appConfig ;
43+
3944 public function __construct (
4045 Backend \BackendInterface $ carddavBackend ,
4146 string $ principalUri ,
@@ -44,6 +49,10 @@ public function __construct(
4449 private ?IGroupManager $ groupManager ,
4550 ) {
4651 parent ::__construct ($ carddavBackend , $ principalUri );
52+
53+ $ this ->l10n = Util::getL10N ('dav ' );
54+ $ this ->config = Server::get (IConfig::class);
55+ $ this ->appConfig = Server::get (IAppConfig::class);
4756 }
4857
4958 /**
@@ -52,19 +61,12 @@ public function __construct(
5261 * @return IAddressBook[]
5362 */
5463 public function getChildren () {
55- if ($ this ->l10n === null ) {
56- $ this ->l10n = \OC ::$ server ->getL10N ('dav ' );
57- }
58- if ($ this ->config === null ) {
59- $ this ->config = Server::get (IConfig::class);
60- }
61-
6264 /** @var string|array $principal */
6365 $ principal = $ this ->principalUri ;
6466 $ addressBooks = $ this ->carddavBackend ->getAddressBooksForUser ($ this ->principalUri );
6567 // add the system address book
6668 $ systemAddressBook = null ;
67- $ systemAddressBookExposed = $ this ->config -> getAppValue ('dav ' , 'system_addressbook_exposed ' , ' yes ' ) === ' yes ' ;
69+ $ systemAddressBookExposed = $ this ->appConfig -> getValueBool ('dav ' , 'system_addressbook_exposed ' , true ) ;
6870 if ($ systemAddressBookExposed && is_string ($ principal ) && $ principal !== 'principals/system/system ' && $ this ->carddavBackend instanceof CardDavBackend) {
6971 $ systemAddressBook = $ this ->carddavBackend ->getAddressBooksByUri ('principals/system/system ' , 'system ' );
7072 if ($ systemAddressBook !== null ) {
0 commit comments