From aac66014ec2aa89453d4e4e546afc2083ebcb0e6 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Fri, 19 Aug 2022 13:15:06 +0200 Subject: [PATCH] MOBILE-4122 about: Check user role to hide survey --- src/core/classes/site.ts | 10 ++++++++++ src/core/features/settings/pages/about/about.html | 4 ++-- src/core/features/settings/pages/about/about.ts | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 7580b54f3..295a60a83 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -388,6 +388,16 @@ export class CoreSite { this.oauthId = oauthId; } + /** + * Check if current user is Admin. + * Works properly since v3.8. See more in: {@link} https://tracker.moodle.org/browse/MDL-65550 + * + * @returns Whether the user is Admin. + */ + isAdmin(): boolean { + return this.getInfo()?.userissiteadmin ?? false; + } + /** * Check if the user authenticated in the site using an OAuth method. * diff --git a/src/core/features/settings/pages/about/about.html b/src/core/features/settings/pages/about/about.html index 98a0e25cb..b70b019fd 100644 --- a/src/core/features/settings/pages/about/about.html +++ b/src/core/features/settings/pages/about/about.html @@ -27,8 +27,8 @@ {{ 'core.settings.accessstatement' | translate }} - + {{ 'core.settings.helpusimprove' | translate }} diff --git a/src/core/features/settings/pages/about/about.ts b/src/core/features/settings/pages/about/about.ts index 3d64b1605..d588de481 100644 --- a/src/core/features/settings/pages/about/about.ts +++ b/src/core/features/settings/pages/about/about.ts @@ -35,6 +35,7 @@ export class CoreSettingsAboutPage { feedbackFormUrl = CoreConstants.CONFIG.feedbackFormUrl ?? 'https://feedback.moodle.org/mobileapp'; a11yStatement = CoreConstants.CONFIG.a11yStatement ?? 'https://apps.moodle.com/admin/tool/policy/view.php?versionid=5'; currentSite?: CoreSite; + showSurvey: boolean | undefined = false; constructor() { this.currentSite = CoreSites.getCurrentSite(); @@ -45,6 +46,7 @@ export class CoreSettingsAboutPage { // Calculate the privacy policy to use. this.privacyPolicy = (this.currentSite && (this.currentSite.getStoredConfig('tool_mobile_apppolicy') || this.currentSite.getStoredConfig('sitepolicy'))) || CoreConstants.CONFIG.privacypolicy; + this.showSurvey = this.currentSite?.isAdmin(); } /**