Merge pull request #2201 from crazyserver/MOBILE-3213

MOBILE-3213 lang: Use a variable to determine minimum version
main
Juan Leyva 2019-12-10 13:39:23 +01:00 committed by GitHub
commit 0941ba9008
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 18 deletions

View File

@ -1620,8 +1620,8 @@
"core.h5p.originator": "h5p", "core.h5p.originator": "h5p",
"core.h5p.pd": "h5p", "core.h5p.pd": "h5p",
"core.h5p.pddl": "h5p", "core.h5p.pddl": "h5p",
"core.h5p.play": "local_moodlemobileapp",
"core.h5p.pdm": "h5p", "core.h5p.pdm": "h5p",
"core.h5p.play": "local_moodlemobileapp",
"core.h5p.resizescript": "h5p", "core.h5p.resizescript": "h5p",
"core.h5p.resubmitScores": "h5p", "core.h5p.resubmitScores": "h5p",
"core.h5p.reuse": "h5p", "core.h5p.reuse": "h5p",

View File

@ -1328,7 +1328,7 @@
"core.back": "Back", "core.back": "Back",
"core.block.blocks": "Blocks", "core.block.blocks": "Blocks",
"core.cancel": "Cancel", "core.cancel": "Cancel",
"core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle 3.1 or later.", "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.",
"core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", "core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.",
"core.captureaudio": "Record audio", "core.captureaudio": "Record audio",
"core.capturedimage": "Taken picture.", "core.capturedimage": "Taken picture.",
@ -1670,7 +1670,6 @@
"core.login.changepasswordinstructions": "You cannot change your password in the app. Please click the following button to open the site in a web browser to change your password. Take into account you need to close the browser after changing the password as you will not be redirected to the app.", "core.login.changepasswordinstructions": "You cannot change your password in the app. Please click the following button to open the site in a web browser to change your password. Take into account you need to close the browser after changing the password as you will not be redirected to the app.",
"core.login.changepasswordlogoutinstructions": "If you prefer to change site or log out, please click the following button:", "core.login.changepasswordlogoutinstructions": "If you prefer to change site or log out, please click the following button:",
"core.login.changepasswordreconnectinstructions": "Click the following button to reconnect to the site. (Take into account that if you didn't change your password successfully, you would return to the previous screen).", "core.login.changepasswordreconnectinstructions": "Click the following button to reconnect to the site. (Take into account that if you didn't change your password successfully, you would return to the previous screen).",
"core.login.checksiteversion": "Check that your site uses Moodle 3.1 or later.",
"core.login.confirmdeletesite": "Are you sure you want to delete the site {{sitename}}?", "core.login.confirmdeletesite": "Are you sure you want to delete the site {{sitename}}?",
"core.login.connect": "Connect!", "core.login.connect": "Connect!",
"core.login.connecttomoodle": "Connect to Moodle", "core.login.connecttomoodle": "Connect to Moodle",
@ -1700,7 +1699,7 @@
"core.login.invalidaccount": "Please check your login details or ask your site administrator to check the site configuration.", "core.login.invalidaccount": "Please check your login details or ask your site administrator to check the site configuration.",
"core.login.invaliddate": "Invalid date", "core.login.invaliddate": "Invalid date",
"core.login.invalidemail": "Invalid email address", "core.login.invalidemail": "Invalid email address",
"core.login.invalidmoodleversion": "<p>Invalid Moodle site version. The Moodle app only supports Moodle systems 3.1 onwards.</p>\n<p>You can contact your site administrators and ask them to update their Moodle system.</p>\n<p>\"Site Administrators\" are the people who manages the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.</p>", "core.login.invalidmoodleversion": "<p>Invalid Moodle site version. The Moodle app only supports Moodle systems {{$a}} onwards.</p>\n<p>You can contact your site administrators and ask them to update their Moodle system.</p>\n<p>\"Site Administrators\" are the people who manages the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.</p>",
"core.login.invalidsite": "The site URL is invalid.", "core.login.invalidsite": "The site URL is invalid.",
"core.login.invalidtime": "Invalid time", "core.login.invalidtime": "Invalid time",
"core.login.invalidurl": "Invalid URL specified", "core.login.invalidurl": "Invalid URL specified",

View File

@ -212,6 +212,7 @@ export class CoreSite {
3.6: 2018120300, 3.6: 2018120300,
3.7: 2019052000 3.7: 2019052000
}; };
static MINIMUM_MOODLE_VERSION = 3.1;
// Possible cache update frequencies. // Possible cache update frequencies.
protected UPDATE_FREQUENCIES = [ protected UPDATE_FREQUENCIES = [
@ -657,7 +658,8 @@ export class CoreSite {
const promise = this.getFromCache(method, data, preSets, false, originalData).catch(() => { const promise = this.getFromCache(method, data, preSets, false, originalData).catch(() => {
if (preSets.forceOffline) { if (preSets.forceOffline) {
// Don't call the WS, just fail. // Don't call the WS, just fail.
return Promise.reject(this.wsProvider.createFakeWSError('core.cannotconnect', true)); return Promise.reject(this.wsProvider.createFakeWSError('core.cannotconnect', true,
{$a: CoreSite.MINIMUM_MOODLE_VERSION}));
} }
// Call the WS. // Call the WS.

View File

@ -2,7 +2,6 @@
"auth_email": "Email-based self-registration", "auth_email": "Email-based self-registration",
"authenticating": "Authenticating", "authenticating": "Authenticating",
"cancel": "Cancel", "cancel": "Cancel",
"checksiteversion": "Check that your site uses Moodle 3.1 or later.",
"changepassword": "Change password", "changepassword": "Change password",
"changepasswordbutton": "Open the change password page", "changepasswordbutton": "Open the change password page",
"changepasswordhelp": "If you have problems changing your password, please contact your site administrator. \"Site Administrators\" are the people who manages the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.", "changepasswordhelp": "If you have problems changing your password, please contact your site administrator. \"Site Administrators\" are the people who manages the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.",
@ -38,7 +37,7 @@
"invalidaccount": "Please check your login details or ask your site administrator to check the site configuration.", "invalidaccount": "Please check your login details or ask your site administrator to check the site configuration.",
"invaliddate": "Invalid date", "invaliddate": "Invalid date",
"invalidemail": "Invalid email address", "invalidemail": "Invalid email address",
"invalidmoodleversion": "<p>Invalid Moodle site version. The Moodle app only supports Moodle systems 3.1 onwards.</p>\n<p>You can contact your site administrators and ask them to update their Moodle system.</p>\n<p>\"Site Administrators\" are the people who manages the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.</p>", "invalidmoodleversion": "<p>Invalid Moodle site version. The Moodle app only supports Moodle systems {{$a}} onwards.</p>\n<p>You can contact your site administrators and ask them to update their Moodle system.</p>\n<p>\"Site Administrators\" are the people who manages the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.</p>",
"invalidsite": "The site URL is invalid.", "invalidsite": "The site URL is invalid.",
"invalidtime": "Invalid time", "invalidtime": "Invalid time",
"invalidurl": "Invalid URL specified", "invalidurl": "Invalid URL specified",

View File

@ -12,7 +12,7 @@
"areyousure": "Are you sure?", "areyousure": "Are you sure?",
"back": "Back", "back": "Back",
"cancel": "Cancel", "cancel": "Cancel",
"cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle 3.1 or later.", "cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.",
"cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", "cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.",
"captureaudio": "Record audio", "captureaudio": "Record audio",
"capturedimage": "Taken picture.", "capturedimage": "Taken picture.",

View File

@ -371,7 +371,7 @@ export class CoreSitesProvider {
} else if (this.textUtils.getErrorMessageFromError(secondError)) { } else if (this.textUtils.getErrorMessageFromError(secondError)) {
return Promise.reject(secondError); return Promise.reject(secondError);
} else { } else {
return this.translate.instant('core.cannotconnect'); return this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION});
} }
}); });
}); });
@ -463,7 +463,8 @@ export class CoreSitesProvider {
error.error = this.translate.instant('core.login.sitehasredirect'); error.error = this.translate.instant('core.login.sitehasredirect');
} else { } else {
// We can't be sure if there is a redirect or not. Display cannot connect error. // We can't be sure if there is a redirect or not. Display cannot connect error.
error.error = this.translate.instant('core.cannotconnect'); error.error = this.translate.instant('core.cannotconnect',
{$a: CoreSite.MINIMUM_MOODLE_VERSION});
} }
return Promise.reject(error); return Promise.reject(error);
@ -508,7 +509,7 @@ export class CoreSitesProvider {
return this.http.post(siteUrl + '/login/token.php', {}).timeout(this.wsProvider.getRequestTimeout()).toPromise() return this.http.post(siteUrl + '/login/token.php', {}).timeout(this.wsProvider.getRequestTimeout()).toPromise()
.catch(() => { .catch(() => {
// Default error messages are kinda bad, return our own message. // Default error messages are kinda bad, return our own message.
return Promise.reject({error: this.translate.instant('core.cannotconnect')}); return Promise.reject({error: this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION})});
}).then((data: any) => { }).then((data: any) => {
if (data.errorcode && (data.errorcode == 'enablewsdescription' || data.errorcode == 'requirecorrectaccess')) { if (data.errorcode && (data.errorcode == 'enablewsdescription' || data.errorcode == 'requirecorrectaccess')) {
@ -550,7 +551,7 @@ export class CoreSitesProvider {
return promise.then((data: any): any => { return promise.then((data: any): any => {
if (typeof data == 'undefined') { if (typeof data == 'undefined') {
return Promise.reject(this.translate.instant('core.cannotconnect')); return Promise.reject(this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION}));
} else { } else {
if (typeof data.token != 'undefined') { if (typeof data.token != 'undefined') {
return { token: data.token, siteUrl: siteUrl, privateToken: data.privatetoken }; return { token: data.token, siteUrl: siteUrl, privateToken: data.privatetoken };
@ -582,7 +583,7 @@ export class CoreSitesProvider {
} }
} }
}, () => { }, () => {
return Promise.reject(this.translate.instant('core.cannotconnect')); return Promise.reject(this.translate.instant('core.cannotconnect', {$a: CoreSite.MINIMUM_MOODLE_VERSION}));
}); });
} }
@ -676,7 +677,8 @@ export class CoreSitesProvider {
*/ */
protected treatInvalidAppVersion(result: number, siteUrl: string, siteId?: string): Promise<any> { protected treatInvalidAppVersion(result: number, siteUrl: string, siteId?: string): Promise<any> {
let errorCode, let errorCode,
errorKey; errorKey,
translateParams;
switch (result) { switch (result) {
case this.MOODLE_APP: case this.MOODLE_APP:
@ -690,6 +692,7 @@ export class CoreSitesProvider {
default: default:
errorCode = 'invalidmoodleversion'; errorCode = 'invalidmoodleversion';
errorKey = 'core.login.invalidmoodleversion'; errorKey = 'core.login.invalidmoodleversion';
translateParams = {$a: CoreSite.MINIMUM_MOODLE_VERSION};
} }
let promise; let promise;
@ -702,7 +705,7 @@ export class CoreSitesProvider {
return promise.then(() => { return promise.then(() => {
return Promise.reject({ return Promise.reject({
error: this.translate.instant(errorKey), error: this.translate.instant(errorKey, translateParams),
errorcode: errorCode, errorcode: errorCode,
loggedout: true loggedout: true
}); });
@ -757,7 +760,7 @@ export class CoreSitesProvider {
} }
const version31 = 2016052300, const version31 = 2016052300,
release31 = '3.1'; release31 = CoreSite.MINIMUM_MOODLE_VERSION;
// Try to validate by version. // Try to validate by version.
if (info.version) { if (info.version) {

View File

@ -315,11 +315,12 @@ export class CoreWSProvider {
* *
* @param message The message to include in the error. * @param message The message to include in the error.
* @param needsTranslate If the message needs to be translated. * @param needsTranslate If the message needs to be translated.
* @param translateParams Translation params, if needed.
* @return Fake WS error. * @return Fake WS error.
*/ */
createFakeWSError(message: string, needsTranslate?: boolean): CoreWSError { createFakeWSError(message: string, needsTranslate?: boolean, translateParams?: {}): CoreWSError {
if (needsTranslate) { if (needsTranslate) {
message = this.translate.instant(message); message = this.translate.instant(message, translateParams);
} }
return { return {