Merge pull request #2124 from albertgasset/MOBILE-3093

Mobile 3093
main
Juan Leyva 2019-10-08 13:43:07 +02:00 committed by GitHub
commit 9a0b960d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1874 additions and 5009 deletions

View File

@ -146,7 +146,7 @@
<plugin name="cordova-plugin-statusbar" spec="^2.4.3" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.4" />
<plugin name="cordova-plugin-zip" spec="^3.1.0" />
<plugin name="cordova-sqlite-storage" spec="^2.6.0" />
<plugin name="cordova-sqlite-storage" spec="^3.4.0" />
<plugin name="nl.kingsquare.cordova.background-audio" spec="^1.0.1" />
<plugin name="phonegap-plugin-push" spec="https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3">
<variable name="ANDROID_SUPPORT_V13_VERSION" value="27.+" />

6673
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -82,7 +82,7 @@
"ajv": "^6.10.2",
"chart.js": "^2.7.2",
"com-darryncampbell-cordova-plugin-intent": "^1.1.7",
"cordova": "8.1.2",
"cordova": "9.0.0",
"cordova-android": "8.0.0",
"cordova-android-support-gradle-release": "^3.0.1",
"cordova-clipboard": "^1.3.0",
@ -106,7 +106,7 @@
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"cordova-plugin-zip": "^3.1.0",
"cordova-sqlite-storage": "^2.6.0",
"cordova-sqlite-storage": "^3.4.0",
"cordova-support-google-services": "^1.2.1",
"es6-promise-plugin": "^4.2.2",
"font-awesome": "^4.7.0",

View File

@ -1564,6 +1564,12 @@
"core.login.auth_email": "auth_email/pluginname",
"core.login.authenticating": "local_moodlemobileapp",
"core.login.cancel": "moodle",
"core.login.changepassword": "moodle",
"core.login.changepasswordbutton": "local_moodlemobileapp",
"core.login.changepasswordhelp": "local_moodlemobileapp",
"core.login.changepassowrdinstructions": "local_moodlemobileapp",
"core.login.changepasswordlogoutinstructions": "local_moodlemobileapp",
"core.login.changepasswordreconnectinstructions": "local_moodlemobileapp",
"core.login.checksiteversion": "local_moodlemobileapp",
"core.login.confirmdeletesite": "local_moodlemobileapp",
"core.login.connect": "local_moodlemobileapp",
@ -1585,6 +1591,7 @@
"core.login.errorupdatesite": "local_moodlemobileapp",
"core.login.findyoursite": "local_moodlemobileapp",
"core.login.firsttime": "moodle",
"core.login.forcepasswordchangenotice": "moodle",
"core.login.forgotten": "moodle",
"core.login.getanothercaptcha": "auth",
"core.login.help": "moodle",

View File

@ -99,7 +99,7 @@ export class MoodleMobileApp implements OnInit {
// Listen for passwordchange and usernotfullysetup events to open InAppBrowser.
this.eventsProvider.on(CoreEventsProvider.PASSWORD_CHANGE_FORCED, (data) => {
this.loginHelper.openInAppForEdit(data.siteId, '/login/change_password.php', 'core.forcepasswordchangenotice', true);
this.loginHelper.passwordChangeForced(data.siteId);
});
this.eventsProvider.on(CoreEventsProvider.USER_NOT_FULLY_SETUP, (data) => {
this.loginHelper.openInAppForEdit(data.siteId, '/user/edit.php', 'core.usernotfullysetup');

View File

@ -1562,6 +1562,12 @@
"core.login.auth_email": "Email-based self-registration",
"core.login.authenticating": "Authenticating",
"core.login.cancel": "Cancel",
"core.login.changepassowrdinstructions": "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.changepassword": "Change password",
"core.login.changepasswordbutton": "Open the change password page",
"core.login.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.",
"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.checksiteversion": "Check that your site uses Moodle 2.4 or later.",
"core.login.confirmdeletesite": "Are you sure you want to delete the site {{sitename}}?",
"core.login.connect": "Connect!",
@ -1583,6 +1589,7 @@
"core.login.errorupdatesite": "An error occurred while updating the site's token.",
"core.login.findyoursite": "Find your site",
"core.login.firsttime": "Is this your first time here?",
"core.login.forcepasswordchangenotice": "You must change your password to proceed.",
"core.login.forgotten": "Forgotten your username or password?",
"core.login.getanothercaptcha": "Get another CAPTCHA",
"core.login.help": "Help",

View File

@ -3,6 +3,12 @@
"authenticating": "Authenticating",
"cancel": "Cancel",
"checksiteversion": "Check that your site uses Moodle 2.4 or later.",
"changepassword": "Change password",
"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.",
"changepassowrdinstructions": "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.",
"changepasswordlogoutinstructions": "If you prefer to change site or log out, please click the following button:",
"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).",
"confirmdeletesite": "Are you sure you want to delete the site {{sitename}}?",
"connect": "Connect!",
"connecttomoodle": "Connect to Moodle",
@ -23,6 +29,7 @@
"errorupdatesite": "An error occurred while updating the site's token.",
"findyoursite": "Find your site",
"firsttime": "Is this your first time here?",
"forcepasswordchangenotice": "You must change your password to proceed.",
"forgotten": "Forgotten your username or password?",
"getanothercaptcha": "Get another CAPTCHA",
"help": "Help",

View File

@ -0,0 +1,27 @@
<ion-header>
<ion-navbar core-back-button>
<ion-title>{{ 'core.login.changepassword' | translate }}</ion-title>
<ion-buttons end>
<button ion-button icon-only (click)="showHelp()" [attr.aria-label]="'core.help' | translate">
<ion-icon name="help-circle"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding class="core-center-view">
<ion-list>
<ion-item text-wrap *ngIf="!changingPassword">
<h2>{{ 'core.login.forcepasswordchangenotice' | translate }}</h2>
<p padding-vertical>{{ 'core.login.changepassowrdinstructions' | translate }}</p>
<button text-wrap ion-button block (click)="openChangePasswordPage()">{{ 'core.login.changepasswordbutton' | translate }}</button>
</ion-item>
<ion-item text-wrap *ngIf="changingPassword">
<p padding-bottom>{{ 'core.login.changepasswordreconnectinstructions' | translate }}</p>
<button text-wrap ion-button block (click)="login()">{{ 'core.login.reconnect' | translate }}</button>
</ion-item>
<ion-item text-wrap>
<p padding-bottom>{{ 'core.login.changepasswordlogoutinstructions' | translate }}</p>
<button text-wrap ion-button block color="light" (click)="logout()">{{ logoutLabel | translate }}</button>
</ion-item>
</ion-list>
</ion-content>

View File

@ -0,0 +1,33 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreLoginChangePasswordPage } from './change-password';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
@NgModule({
declarations: [
CoreLoginChangePasswordPage
],
imports: [
CoreComponentsModule,
CoreDirectivesModule,
IonicPageModule.forChild(CoreLoginChangePasswordPage),
TranslateModule.forChild()
]
})
export class CoreLoginChangePasswordPageModule {}

View File

@ -0,0 +1,69 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreSitesProvider } from '@providers/sites';
import { CoreLoginHelperProvider } from '../../providers/helper';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
/**
* Page that shows instructions to change the password.
*/
@IonicPage({ segment: 'core-login-change-password' })
@Component({
selector: 'page-core-change-password',
templateUrl: 'change-password.html',
})
export class CoreLoginChangePasswordPage {
changingPassword = false;
logoutLabel: string;
constructor(private translate: TranslateService, private sitesProvider: CoreSitesProvider,
private loginHelper: CoreLoginHelperProvider, private domUtls: CoreDomUtilsProvider) {
this.logoutLabel = this.loginHelper.getLogoutLabel();
}
/**
* Show a help modal.
*/
showHelp(): void {
this.domUtls.showAlert(this.translate.instant('core.help'), this.translate.instant('core.login.changepasswordhelp'));
}
/**
* Open the change password page in a browser.
*/
openChangePasswordPage(): void {
this.loginHelper.openInAppForEdit(this.sitesProvider.getCurrentSiteId(), '/login/change_password.php', undefined, true);
this.changingPassword = true;
}
/**
* Login the user.
*/
login(): void {
this.loginHelper.goToSiteInitialPage();
this.changingPassword = false;
}
/**
* Logout the user.
*/
logout(): void {
this.sitesProvider.logout();
this.changingPassword = false;
}
}

View File

@ -32,6 +32,7 @@ import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreConfigConstants } from '../../../configconstants';
import { CoreConstants } from '@core/constants';
import { Md5 } from 'ts-md5/dist/md5';
import { CoreSite } from '@classes/site';
/**
* Data related to a SSO authentication.
@ -367,6 +368,19 @@ export class CoreLoginHelperProvider {
return errors;
}
/**
* Returns the logout label of a site.
*
* @param site Site. If not defined, use current site.
* @return The string key.
*/
getLogoutLabel(site?: CoreSite): string {
site = site || this.sitesProvider.getCurrentSite();
const config = site.getStoredConfig();
return 'core.mainmenu.' + (config && config.tool_mobile_forcelogout == '1' ? 'logout' : 'changesite');
}
/**
* Get the site policy.
*
@ -796,7 +810,7 @@ export class CoreLoginHelperProvider {
this.utils.openInApp(siteUrl + '/login/forgot_password.php');
}
/*
/**
* Function to open in app browser to change password or complete user profile.
*
* @param siteId The site ID.
@ -804,7 +818,7 @@ export class CoreLoginHelperProvider {
* @param alertMessage The key of the message to display before opening the in app browser.
* @param invalidateCache Whether to invalidate site's cache (e.g. when the user is forced to change password).
*/
openInAppForEdit(siteId: string, path: string, alertMessage: string, invalidateCache?: boolean): void {
openInAppForEdit(siteId: string, path: string, alertMessage?: string, invalidateCache?: boolean): void {
if (!siteId || siteId !== this.sitesProvider.getCurrentSiteId()) {
// Site that triggered the event is not current site, nothing to do.
return;
@ -824,7 +838,9 @@ export class CoreLoginHelperProvider {
}
// Open change password.
alertMessage = this.translate.instant(alertMessage) + '<br>' + this.translate.instant('core.redirectingtosite');
if (alertMessage) {
alertMessage = this.translate.instant(alertMessage) + '<br>' + this.translate.instant('core.redirectingtosite');
}
currentSite.openInAppWithAutoLogin(siteUrl + path, undefined, alertMessage).then(() => {
this.waitingForBrowser = true;
}).finally(() => {
@ -833,6 +849,28 @@ export class CoreLoginHelperProvider {
}
}
/**
* Function that should be called when password change is forced. Reserved for core use.
*
* @param siteId The site ID.
*/
passwordChangeForced(siteId: string): void {
const currentSite = this.sitesProvider.getCurrentSite();
if (!currentSite || siteId !== currentSite.getId()) {
return; // Site that triggered the event is not current site.
}
const rootNavCtrl = this.appProvider.getRootNavController(),
activePage = rootNavCtrl.getActive();
// If current page is already change password, stop.
if (activePage && activePage.component && activePage.component.name == 'CoreLoginChangePasswordPage') {
return;
}
rootNavCtrl.setRoot('CoreLoginChangePasswordPage', {siteId});
}
/**
* Prepare the app to perform SSO login.
*

View File

@ -18,6 +18,7 @@ import { CoreEventsProvider } from '@providers/events';
import { CoreSitesProvider } from '@providers/sites';
import { CoreMainMenuDelegate, CoreMainMenuHandlerData } from '../../providers/delegate';
import { CoreMainMenuProvider, CoreMainMenuCustomItem } from '../../providers/mainmenu';
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
/**
* Page that displays the list of main menu options that aren't in the tabs.
@ -46,7 +47,7 @@ export class CoreMainMenuMorePage implements OnDestroy {
constructor(private menuDelegate: CoreMainMenuDelegate, private sitesProvider: CoreSitesProvider,
private navCtrl: NavController, private mainMenuProvider: CoreMainMenuProvider,
eventsProvider: CoreEventsProvider) {
eventsProvider: CoreEventsProvider, private loginHelper: CoreLoginHelperProvider) {
this.langObserver = eventsProvider.on(CoreEventsProvider.LANGUAGE_CHANGED, this.loadSiteInfo.bind(this));
this.updateSiteObserver = eventsProvider.on(CoreEventsProvider.SITE_UPDATED, this.loadSiteInfo.bind(this),
@ -104,13 +105,12 @@ export class CoreMainMenuMorePage implements OnDestroy {
* Load the site info required by the view.
*/
protected loadSiteInfo(): void {
const currentSite = this.sitesProvider.getCurrentSite(),
config = currentSite.getStoredConfig();
const currentSite = this.sitesProvider.getCurrentSite();
this.siteInfo = currentSite.getInfo();
this.siteName = currentSite.getSiteName();
this.siteUrl = currentSite.getURL();
this.logoutLabel = 'core.mainmenu.' + (config && config.tool_mobile_forcelogout == '1' ? 'logout' : 'changesite');
this.logoutLabel = this.loginHelper.getLogoutLabel(currentSite);
this.showWeb = !currentSite.isFeatureDisabled('CoreMainMenuDelegate_website');
this.showHelp = !currentSite.isFeatureDisabled('CoreMainMenuDelegate_help');