Merge pull request #2873 from crazyserver/MOBILE-3320

MOBILE-3320 core: Add WP_PROVIDER constant checks
main
Dani Palou 2021-07-06 10:34:31 +02:00 committed by GitHub
commit 335b2b10e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -70,7 +70,6 @@ export class CoreSitesProvider {
protected static readonly VALID_VERSION = 1;
protected static readonly INVALID_VERSION = -1;
protected isWPApp = false;
protected logger: CoreLogger;
protected services = {};
protected sessionRestored = false;
@ -639,21 +638,28 @@ export class CoreSitesProvider {
protected validateWorkplaceVersion(info: CoreSiteInfoResponse): number {
const isWorkplace = !!info.functions && info.functions.some((func) => func.name == 'tool_program_get_user_programs');
if (typeof this.isWPApp == 'undefined') {
this.isWPApp = false; // @todo
}
const isWPEnabled = this.isWorkplaceEnabled();
if (!this.isWPApp && isWorkplace) {
if (!isWPEnabled && isWorkplace) {
return CoreSitesProvider.WORKPLACE_APP;
}
if (this.isWPApp && !isWorkplace) {
if (isWPEnabled && !isWorkplace) {
return CoreSitesProvider.MOODLE_APP;
}
return CoreSitesProvider.VALID_VERSION;
}
/**
* Check if the app is workplace enabled.
*
* @return If the app is workplace enabled.
*/
protected isWorkplaceEnabled(): boolean {
return false;
}
/**
* Returns the release number from site release info.
*