From c0615e3a55885e341bb82e2f8fdb3b2f8e6f49c9 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Wed, 27 Nov 2019 07:47:47 +0100 Subject: Move to new nextcloud npm packages Signed-off-by: Georg Ehrke --- lib/Controller/PersonalController.php | 19 +------------------ lib/Settings/WhereIsYourDataSettings.php | 23 +++++++++++++++++++++++ lib/Settings/WhoHasAccessSettings.php | 22 +++++++++++++--------- 3 files changed, 37 insertions(+), 27 deletions(-) (limited to 'lib') diff --git a/lib/Controller/PersonalController.php b/lib/Controller/PersonalController.php index 6b7a56b..4b94075 100644 --- a/lib/Controller/PersonalController.php +++ b/lib/Controller/PersonalController.php @@ -64,23 +64,6 @@ class PersonalController extends Controller { $this->dbConnection = $dbConnection; } - /** - * @NoAdminRequired - * - * @return JSONResponse - */ - public function getReadableLocation():JSONResponse { - $location = $this->config->getAppValue($this->appName, 'readableLocation'); - - if ($location === null) { - return new JSONResponse([], Http::STATUS_NOT_FOUND); - } - - return new JSONResponse([ - 'code' => $location, - ], Http::STATUS_OK); - } - /** * @NoAdminRequired * @@ -107,7 +90,7 @@ class PersonalController extends Controller { 'internal' => true, ]; } - + $query = $this->dbConnection->getQueryBuilder(); $query->select(['id', 'displayname']) ->from('privacy_admins'); diff --git a/lib/Settings/WhereIsYourDataSettings.php b/lib/Settings/WhereIsYourDataSettings.php index a640e62..5eb0d19 100644 --- a/lib/Settings/WhereIsYourDataSettings.php +++ b/lib/Settings/WhereIsYourDataSettings.php @@ -22,6 +22,8 @@ namespace OCA\Privacy\Settings; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IConfig; +use OCP\IInitialStateService; use OCP\Settings\ISettings; /** @@ -31,10 +33,31 @@ use OCP\Settings\ISettings; */ class WhereIsYourDataSettings implements ISettings { + /** @var IInitialStateService */ + private $initialStateService; + + /** @var IConfig */ + private $config; + + /** + * MissionSettings constructor. + * + * @param IInitialStateService $initialStateService + * @param IConfig $config + */ + public function __construct(IInitialStateService $initialStateService, + IConfig $config) { + $this->initialStateService = $initialStateService; + $this->config = $config; + } + /** * @return TemplateResponse */ public function getForm():TemplateResponse { + $location = $this->config->getAppValue('privacy', 'readableLocation'); + $this->initialStateService->provideInitialState('privacy', 'location', $location ?: ''); + return new TemplateResponse('privacy', 'where-is-your-data'); } diff --git a/lib/Settings/WhoHasAccessSettings.php b/lib/Settings/WhoHasAccessSettings.php index 64aeaeb..0227103 100644 --- a/lib/Settings/WhoHasAccessSettings.php +++ b/lib/Settings/WhoHasAccessSettings.php @@ -26,6 +26,7 @@ use OCA\Theming\ThemingDefaults; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\Encryption\IManager as IEncryptionManager; +use OCP\IInitialStateService; use OCP\Settings\ISettings; /** @@ -41,16 +42,22 @@ class WhoHasAccessSettings implements ISettings { /** @var IEncryptionManager */ private $encryptionManager; + /** @var IInitialStateService */ + private $initialStateService; + /** * WhoHasAccessSettings constructor. * * @param IConfig $config * @param IEncryptionManager $manager + * @param IInitialStateService $initialStateService */ - public function __construct(IConfig $config, IEncryptionManager $manager) { + public function __construct(IConfig $config, + IEncryptionManager $manager, + IInitialStateService $initialStateService) { $this->config = $config; $this->encryptionManager = $manager; - + $this->initialStateService = $initialStateService; } /** @@ -64,14 +71,11 @@ class WhoHasAccessSettings implements ISettings { $privacyPolicyUrl = null; } - $fullDiskEncryption = $this->config->getAppValue('privacy', 'fullDiskEncryptionEnabled', '0'); - $serverSideEncryption = $this->encryptionManager->isEnabled(); + $this->initialStateService->provideInitialState('privacy', 'privacyPolicyUrl', $privacyPolicyUrl); + $this->initialStateService->provideInitialState('privacy', 'fullDiskEncryptionEnabled', $this->config->getAppValue('privacy', 'fullDiskEncryptionEnabled', '0')); + $this->initialStateService->provideInitialState('privacy', 'serverSideEncryptionEnabled', $this->encryptionManager->isEnabled() ? '1' : '0'); - return new TemplateResponse('privacy', 'who-has-access', [ - 'privacyPolicyUrl' => $privacyPolicyUrl, - 'fullDiskEncryptionEnabled' => $fullDiskEncryption, - 'serverSideEncryptionEnabled' => $serverSideEncryption ? '1' : '0', - ]); + return new TemplateResponse('privacy', 'who-has-access'); } /** -- cgit v1.2.3