Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2022-03-11 05:11:28 +0300
committerChristopher Ng <chrng8@gmail.com>2022-03-18 05:55:12 +0300
commit1fc0b4320c8921ad59bf4d41a88bf9936e1f653d (patch)
tree8d630f864f4a2760f72307e68553cc2ee0c516d4 /apps/settings
parentd364edcf6a18fa237dc53f6b95614851ed5fdc9a (diff)
Add global profile toggle config
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/settings')
-rw-r--r--apps/settings/lib/Settings/Personal/PersonalInfo.php8
-rw-r--r--apps/settings/src/main-personal-info.js31
-rw-r--r--apps/settings/templates/settings/personal/personal.info.php42
-rw-r--r--apps/settings/tests/Settings/Admin/ServerTest.php4
4 files changed, 52 insertions, 33 deletions
diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php
index def7e19f006..4bac8e67fb7 100644
--- a/apps/settings/lib/Settings/Personal/PersonalInfo.php
+++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php
@@ -56,7 +56,6 @@ use OCP\Notification\IManager;
use OCP\Settings\ISettings;
class PersonalInfo implements ISettings {
- use \OC\Profile\TProfileHelper;
/** @var IConfig */
private $config;
@@ -166,7 +165,8 @@ class PersonalInfo implements ISettings {
'twitterScope' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getScope(),
'twitterVerification' => $account->getProperty(IAccountManager::PROPERTY_TWITTER)->getVerified(),
'groups' => $this->getGroups($user),
- 'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService()
+ 'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
+ 'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
] + $messageParameters + $languageParameters + $localeParameters;
$personalInfoParameters = [
@@ -174,7 +174,8 @@ class PersonalInfo implements ISettings {
'displayNameMap' => $this->getDisplayNameMap($account),
'emailMap' => $this->getEmailMap($account),
'languageMap' => $this->getLanguageMap($user),
- 'profileEnabled' => $this->isProfileEnabled($account),
+ 'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
+ 'profileEnabled' => $this->profileManager->isProfileEnabled($user),
'organisationMap' => $this->getOrganisationMap($account),
'roleMap' => $this->getRoleMap($account),
'headlineMap' => $this->getHeadlineMap($account),
@@ -190,6 +191,7 @@ class PersonalInfo implements ISettings {
'profileConfig' => $this->profileManager->getProfileConfigWithMetadata($user, $user),
];
+ $this->initialStateService->provideInitialState('profileEnabledGlobally', $this->profileManager->isProfileEnabled());
$this->initialStateService->provideInitialState('personalInfoParameters', $personalInfoParameters);
$this->initialStateService->provideInitialState('accountParameters', $accountParameters);
$this->initialStateService->provideInitialState('profileParameters', $profileParameters);
diff --git a/apps/settings/src/main-personal-info.js b/apps/settings/src/main-personal-info.js
index 398518984a0..7694fa4ff6d 100644
--- a/apps/settings/src/main-personal-info.js
+++ b/apps/settings/src/main-personal-info.js
@@ -22,6 +22,7 @@
import Vue from 'vue'
import { getRequestToken } from '@nextcloud/auth'
+import { loadState } from '@nextcloud/initial-state'
import { translate as t } from '@nextcloud/l10n'
import '@nextcloud/dialogs/styles/toast.scss'
@@ -39,6 +40,8 @@ import ProfileVisibilitySection from './components/PersonalInfo/ProfileVisibilit
__webpack_nonce__ = btoa(getRequestToken())
+const profileEnabledGlobally = loadState('settings', 'profileEnabledGlobally', true)
+
Vue.mixin({
props: {
logger,
@@ -51,19 +54,23 @@ Vue.mixin({
const DisplayNameView = Vue.extend(DisplayNameSection)
const EmailView = Vue.extend(EmailSection)
const LanguageView = Vue.extend(LanguageSection)
-const ProfileView = Vue.extend(ProfileSection)
-const OrganisationView = Vue.extend(OrganisationSection)
-const RoleView = Vue.extend(RoleSection)
-const HeadlineView = Vue.extend(HeadlineSection)
-const BiographyView = Vue.extend(BiographySection)
-const ProfileVisibilityView = Vue.extend(ProfileVisibilitySection)
new DisplayNameView().$mount('#vue-displayname-section')
new EmailView().$mount('#vue-email-section')
new LanguageView().$mount('#vue-language-section')
-new ProfileView().$mount('#vue-profile-section')
-new OrganisationView().$mount('#vue-organisation-section')
-new RoleView().$mount('#vue-role-section')
-new HeadlineView().$mount('#vue-headline-section')
-new BiographyView().$mount('#vue-biography-section')
-new ProfileVisibilityView().$mount('#vue-profile-visibility-section')
+
+if (profileEnabledGlobally) {
+ const ProfileView = Vue.extend(ProfileSection)
+ const OrganisationView = Vue.extend(OrganisationSection)
+ const RoleView = Vue.extend(RoleSection)
+ const HeadlineView = Vue.extend(HeadlineSection)
+ const BiographyView = Vue.extend(BiographySection)
+ const ProfileVisibilityView = Vue.extend(ProfileVisibilitySection)
+
+ new ProfileView().$mount('#vue-profile-section')
+ new OrganisationView().$mount('#vue-organisation-section')
+ new RoleView().$mount('#vue-role-section')
+ new HeadlineView().$mount('#vue-headline-section')
+ new BiographyView().$mount('#vue-biography-section')
+ new ProfileVisibilityView().$mount('#vue-profile-visibility-section')
+}
diff --git a/apps/settings/templates/settings/personal/personal.info.php b/apps/settings/templates/settings/personal/personal.info.php
index 19265ebfc85..98009cc52be 100644
--- a/apps/settings/templates/settings/personal/personal.info.php
+++ b/apps/settings/templates/settings/personal/personal.info.php
@@ -239,24 +239,28 @@ script('settings', [
<input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>">
</form>
</div>
- <div class="personal-settings-setting-box">
- <div id="vue-organisation-section"></div>
- </div>
- <div class="personal-settings-setting-box">
- <div id="vue-role-section"></div>
- </div>
- <div class="personal-settings-setting-box">
- <div id="vue-headline-section"></div>
- </div>
- <div class="personal-settings-setting-box">
- <div id="vue-biography-section"></div>
- </div>
+ <?php if ($_['profileEnabledGlobally']) : ?>
+ <div class="personal-settings-setting-box">
+ <div id="vue-organisation-section"></div>
+ </div>
+ <div class="personal-settings-setting-box">
+ <div id="vue-role-section"></div>
+ </div>
+ <div class="personal-settings-setting-box">
+ <div id="vue-headline-section"></div>
+ </div>
+ <div class="personal-settings-setting-box">
+ <div id="vue-biography-section"></div>
+ </div>
+ <?php endif; ?>
</div>
<div class="profile-settings-container">
- <div class="personal-settings-setting-box">
- <div id="vue-profile-section"></div>
- </div>
+ <?php if ($_['profileEnabledGlobally']) : ?>
+ <div class="personal-settings-setting-box">
+ <div id="vue-profile-section"></div>
+ </div>
+ <?php endif; ?>
<div class="personal-settings-setting-box personal-settings-language-box">
<div id="vue-language-section"></div>
</div>
@@ -304,6 +308,8 @@ script('settings', [
</div>
-<div class="personal-settings-section">
- <div id="vue-profile-visibility-section"></div>
-</div>
+<?php if ($_['profileEnabledGlobally']) : ?>
+ <div class="personal-settings-section">
+ <div id="vue-profile-visibility-section"></div>
+ </div>
+<?php endif; ?>
diff --git a/apps/settings/tests/Settings/Admin/ServerTest.php b/apps/settings/tests/Settings/Admin/ServerTest.php
index b30ed863f89..045dc60bf98 100644
--- a/apps/settings/tests/Settings/Admin/ServerTest.php
+++ b/apps/settings/tests/Settings/Admin/ServerTest.php
@@ -92,6 +92,10 @@ class ServerTest extends TestCase {
->method('getAppValue')
->with('core', 'cronErrors')
->willReturn('');
+ $this->profileManager
+ ->expects($this->exactly(2))
+ ->method('isProfileEnabled')
+ ->willReturn(true);
$expected = new TemplateResponse(
'settings',
'settings/admin/server',