Skip to content

Commit 34dc165

Browse files
authored
Merge pull request #13097 from nextcloud/feature/11319/where-is-your-data
Where is your data?
2 parents 2e7eb34 + 587a140 commit 34dc165

19 files changed

Lines changed: 762 additions & 180 deletions

File tree

apps/theming/lib/Settings/Section.php

Lines changed: 0 additions & 83 deletions
This file was deleted.

apps/theming/tests/ServicesTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
use OCA\Theming\Capabilities;
2727
use OCA\Theming\Controller\ThemingController;
2828
use OCA\Theming\Settings\Admin;
29-
use OCA\Theming\Settings\Section;
3029
use OCA\Theming\ThemingDefaults;
3130
use OCA\Theming\Util;
3231
use OCP\AppFramework\App;
3332
use OCP\Capabilities\ICapability;
3433
use OCP\IL10N;
35-
use OCP\Settings\ISection;
3634
use OCP\Settings\ISettings;
3735
use Test\TestCase;
3836

@@ -72,8 +70,6 @@ public function queryData() {
7270
// Settings
7371
[Admin::class],
7472
[Admin::class, ISettings::class],
75-
[Section::class],
76-
[Section::class, ISection::class],
7773
];
7874
}
7975

apps/theming/tests/Settings/SectionTest.php

Lines changed: 0 additions & 77 deletions
This file was deleted.

core/css/styles.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ a {
6060
* {
6161
cursor: pointer;
6262
}
63-
}
6463

65-
a.external {
66-
margin: 0 3px;
67-
text-decoration: underline;
64+
&.external {
65+
margin: 0 3px;
66+
text-decoration: underline;
67+
}
6868
}
6969

7070
input {

lib/private/Settings/Manager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public function getAdminSections(): array {
192192
1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
193193
5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
194194
10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
195+
30 => [new Section('theming', $this->l->t('Theming'), 0, $this->url->imagePath('settings', 'theming-dark.svg'))],
195196
50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts.svg'))],
196197
98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
197198
];
@@ -237,6 +238,10 @@ private function getBuiltInAdminSettings($section): array {
237238
$form = $this->container->query(Admin\Security::class);
238239
$forms[$form->getPriority()] = [$form];
239240
}
241+
if ($section === 'theming') {
242+
$form = $this->container->query(Theming\ServerInfo::class);
243+
$forms[$form->getPriority()] = [$form];
244+
}
240245
if ($section === 'sharing') {
241246
/** @var ISettings $form */
242247
$form = $this->container->query(Admin\Sharing::class);

lib/private/Settings/Personal/PersonalInfo.php

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
namespace OC\Settings\Personal;
2727

2828
use OC\Accounts\AccountManager;
29+
use OC\Settings\Theming\ServerInfo;
2930
use OCA\FederatedFileSharing\AppInfo\Application;
3031
use OCP\App\IAppManager;
3132
use OCP\AppFramework\Http\TemplateResponse;
@@ -38,6 +39,7 @@
3839
use OCP\IUserManager;
3940
use OCP\L10N\IFactory;
4041
use OCP\Settings\ISettings;
42+
use OCP\Encryption\IManager as EncryptionManager;
4143

4244
class PersonalInfo implements ISettings {
4345

@@ -55,14 +57,18 @@ class PersonalInfo implements ISettings {
5557
private $l10nFactory;
5658
/** @var IL10N */
5759
private $l;
60+
/** @var EncryptionManager */
61+
private $encryptionManager;
5862

5963
/**
6064
* @param IConfig $config
6165
* @param IUserManager $userManager
6266
* @param IGroupManager $groupManager
6367
* @param AccountManager $accountManager
68+
* @param IAppManager $appManager
6469
* @param IFactory $l10nFactory
6570
* @param IL10N $l
71+
* @param EncryptionManager $encryptionManager
6672
*/
6773
public function __construct(
6874
IConfig $config,
@@ -71,7 +77,8 @@ public function __construct(
7177
AccountManager $accountManager,
7278
IAppManager $appManager,
7379
IFactory $l10nFactory,
74-
IL10N $l
80+
IL10N $l,
81+
EncryptionManager $encryptionManager
7582
) {
7683
$this->config = $config;
7784
$this->userManager = $userManager;
@@ -80,6 +87,7 @@ public function __construct(
8087
$this->appManager = $appManager;
8188
$this->l10nFactory = $l10nFactory;
8289
$this->l = $l;
90+
$this->encryptionManager = $encryptionManager;
8391
}
8492

8593
/**
@@ -135,12 +143,40 @@ public function getForm() {
135143
'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'],
136144
'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
137145
'groups' => $this->getGroups($user),
138-
] + $messageParameters + $languageParameters + $localeParameters;
139-
146+
] + $this->getWhereIsYourDataParams() + $messageParameters + $languageParameters + $localeParameters;
140147

141148
return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
142149
}
143150

151+
/**
152+
* Returns the "where is your data" template params.
153+
*
154+
* @return array
155+
*/
156+
private function getWhereIsYourDataParams(): array {
157+
158+
$adminContactConfigId = $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER_ADMIN_CONTACT);
159+
$adminContact = $this->userManager->get($adminContactConfigId);
160+
161+
$params = [
162+
'dataLocation' => $this->config->getSystemValue(ServerInfo::SETTING_LOCATION),
163+
'provider' => $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER),
164+
'providerLink' => $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER_WEBSITE),
165+
'providerPrivacyLink' => $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER_PRIVACY_LINK),
166+
'encryptionEnabled' => $this->encryptionManager->isEnabled(),
167+
'adminName' => $adminContact !== null ? $adminContact->getDisplayName() : '',
168+
'adminMail' => $adminContact !== null ? $adminContact->getEMailAddress() : ''
169+
];
170+
171+
$params['show_where_is_your_data_section'] = empty($params['dataLocation']) === false
172+
|| empty($params['provider']) === false
173+
|| $params['encryptionEnabled'] === true
174+
|| empty($params['adminName']) === false;
175+
176+
return $params;
177+
178+
}
179+
144180
/**
145181
* @return string the section ID, e.g. 'sharing'
146182
* @since 9.1
@@ -202,7 +238,7 @@ private function getLanguages(IUser $user) {
202238
$userLang = $languages['commonlanguages'][$userLangIndex];
203239
// search in the other languages
204240
if ($userLangIndex === false) {
205-
$userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
241+
$userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
206242
$userLang = $languages['languages'][$userLangIndex];
207243
}
208244
// if user language is not available but set somehow: show the actual code as name

0 commit comments

Comments
 (0)