99 */
1010namespace OCA \DAV \CardDAV ;
1111
12+ use OCA \DAV \AppInfo \Application ;
1213use OCA \DAV \AppInfo \PluginManager ;
1314use OCA \DAV \CardDAV \Integration \ExternalAddressBook ;
1415use OCA \DAV \CardDAV \Integration \IAddressBookProvider ;
16+ use OCA \DAV \ConfigLexicon ;
1517use OCA \Federation \TrustedServers ;
1618use OCP \AppFramework \QueryException ;
19+ use OCP \IAppConfig ;
1720use OCP \IConfig ;
1821use OCP \IGroupManager ;
1922use OCP \IL10N ;
2023use OCP \IRequest ;
2124use OCP \IUser ;
2225use OCP \IUserSession ;
2326use OCP \Server ;
27+ use OCP \Util ;
2428use Psr \Container \ContainerExceptionInterface ;
2529use Psr \Container \NotFoundExceptionInterface ;
2630use Sabre \CardDAV \Backend ;
3034use function array_map ;
3135
3236class UserAddressBooks extends \Sabre \CardDAV \AddressBookHome {
33- /** @var IL10N */
34- protected $ l10n ;
35-
36- /** @var IConfig */
37- protected $ config ;
37+ protected IL10N $ l10n ;
38+ protected IConfig $ config ;
39+ protected IAppConfig $ appConfig ;
3840
3941 public function __construct (
4042 Backend \BackendInterface $ carddavBackend ,
@@ -44,6 +46,10 @@ public function __construct(
4446 private ?IGroupManager $ groupManager ,
4547 ) {
4648 parent ::__construct ($ carddavBackend , $ principalUri );
49+
50+ $ this ->l10n = Util::getL10N ('dav ' );
51+ $ this ->config = Server::get (IConfig::class);
52+ $ this ->appConfig = Server::get (IAppConfig::class);
4753 }
4854
4955 /**
@@ -52,19 +58,12 @@ public function __construct(
5258 * @return IAddressBook[]
5359 */
5460 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-
6261 /** @var string|array $principal */
6362 $ principal = $ this ->principalUri ;
6463 $ addressBooks = $ this ->carddavBackend ->getAddressBooksForUser ($ this ->principalUri );
6564 // add the system address book
6665 $ systemAddressBook = null ;
67- $ systemAddressBookExposed = $ this ->config -> getAppValue ( ' dav ' , ' system_addressbook_exposed ' , ' yes ' ) === ' yes ' ;
66+ $ systemAddressBookExposed = $ this ->appConfig -> getValueBool (Application:: APP_ID , ConfigLexicon:: SYSTEM_ADDRESSBOOK_EXPOSED ) ;
6867 if ($ systemAddressBookExposed && is_string ($ principal ) && $ principal !== 'principals/system/system ' && $ this ->carddavBackend instanceof CardDavBackend) {
6968 $ systemAddressBook = $ this ->carddavBackend ->getAddressBooksByUri ('principals/system/system ' , 'system ' );
7069 if ($ systemAddressBook !== null ) {
0 commit comments