Skip to content

Commit 29f78e2

Browse files
authored
Merge pull request #59956 from nextcloud/fix-reenabling-system-address-book-in-stable32
[stable32] Fix reenabling system address book
2 parents f721cb2 + b26329e commit 29f78e2

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

apps/dav/lib/CardDAV/UserAddressBooks.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
use OCA\DAV\CardDAV\Integration\IAddressBookProvider;
1515
use OCA\Federation\TrustedServers;
1616
use OCP\AppFramework\QueryException;
17+
use OCP\IAppConfig;
1718
use OCP\IConfig;
1819
use OCP\IGroupManager;
1920
use OCP\IL10N;
2021
use OCP\IRequest;
2122
use OCP\IUser;
2223
use OCP\IUserSession;
2324
use OCP\Server;
25+
use OCP\Util;
2426
use Psr\Container\ContainerExceptionInterface;
2527
use Psr\Container\NotFoundExceptionInterface;
2628
use 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) {

build/psalm-baseline.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,6 @@
592592
</DeprecatedMethod>
593593
</file>
594594
<file src="apps/dav/lib/CardDAV/UserAddressBooks.php">
595-
<DeprecatedMethod>
596-
<code><![CDATA[getAppValue]]></code>
597-
<code><![CDATA[getL10N]]></code>
598-
</DeprecatedMethod>
599595
<InvalidArgument>
600596
<code><![CDATA[$this->principalUri]]></code>
601597
<code><![CDATA[$this->principalUri]]></code>

0 commit comments

Comments
 (0)