2
0

MOBILE-2317 user: Solve PR errors and lints

This commit is contained in:
Pau Ferrer Ocaña 2018-01-25 13:19:11 +01:00
parent 96d548e706
commit debfb5c6c6
54 changed files with 158 additions and 135 deletions
src
addon
calendar
userprofilefield
checkbox
component
providers
datetime
component
providers
menu
component
providers
text
component
providers
textarea
component
providers
classes
components
course-picker-menu
rich-text-editor
split-view
tabs
core
contentlinks/providers
course
components/unsupported-module
pages/unsupported-module
providers
courses
components
course-list-item
course-progress
providers
emulator/providers
fileuploader/providers
login/pages/email-signup
mainmenu/providers
sitehome/components
all-course-list
categories
course-search
enrolled-course-list
index
news
user
directives
providers

@ -46,7 +46,7 @@ export class AddonCalendarModule {
localNotificationsProvider.registerClick(AddonCalendarProvider.COMPONENT, (data) => { localNotificationsProvider.registerClick(AddonCalendarProvider.COMPONENT, (data) => {
if (data.eventid) { if (data.eventid) {
initDelegate.ready().then(() => { initDelegate.ready().then(() => {
calendarProvider.isDisabled(data.siteId).then(function(disabled) { calendarProvider.isDisabled(data.siteId).then((disabled) => {
if (disabled) { if (disabled) {
// The calendar is disabled in the site, don't open it. // The calendar is disabled in the site, don't open it.
return; return;

@ -45,10 +45,10 @@ export class AddonCalendarEventPage {
courseName: string; courseName: string;
notificationsEnabled = false; notificationsEnabled = false;
constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, private navParams: NavParams, constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, navParams: NavParams,
private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider,
private calendarHelper: AddonCalendarHelperProvider, private sitesProvider: CoreSitesProvider, private calendarHelper: AddonCalendarHelperProvider, sitesProvider: CoreSitesProvider,
private localNotificationsProvider: CoreLocalNotificationsProvider, private courseProvider: CoreCourseProvider) { localNotificationsProvider: CoreLocalNotificationsProvider, private courseProvider: CoreCourseProvider) {
this.eventId = navParams.get('id'); this.eventId = navParams.get('id');
this.notificationsEnabled = localNotificationsProvider.isAvailable(); this.notificationsEnabled = localNotificationsProvider.isAvailable();

@ -63,11 +63,11 @@ export class AddonCalendarListPage implements OnDestroy {
course: this.allCourses course: this.allCourses
}; };
constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, private navParams: NavParams, constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, navParams: NavParams,
private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, private utils: CoreUtilsProvider, private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, private utils: CoreUtilsProvider,
private calendarHelper: AddonCalendarHelperProvider, private sitesProvider: CoreSitesProvider, private calendarHelper: AddonCalendarHelperProvider, sitesProvider: CoreSitesProvider,
private localNotificationsProvider: CoreLocalNotificationsProvider, private popoverCtrl: PopoverController, localNotificationsProvider: CoreLocalNotificationsProvider, private popoverCtrl: PopoverController,
private eventsProvider: CoreEventsProvider, private navCtrl: NavController, private appProvider: CoreAppProvider) { eventsProvider: CoreEventsProvider, private navCtrl: NavController, appProvider: CoreAppProvider) {
this.siteHomeId = sitesProvider.getCurrentSite().getSiteHomeId(); this.siteHomeId = sitesProvider.getCurrentSite().getSiteHomeId();
this.notificationsEnabled = localNotificationsProvider.isAvailable(); this.notificationsEnabled = localNotificationsProvider.isAvailable();

@ -14,7 +14,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreLoggerProvider } from '../../../providers/logger'; import { CoreLoggerProvider } from '../../../providers/logger';
import { CoreSitesProvider } from '../../../providers/sites';
import { CoreCourseProvider } from '../../../core/course/providers/course'; import { CoreCourseProvider } from '../../../core/course/providers/course';
/** /**
@ -32,7 +31,7 @@ export class AddonCalendarHelperProvider {
'category': 'albums' 'category': 'albums'
}; };
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private courseProvider: CoreCourseProvider) { constructor(logger: CoreLoggerProvider, private courseProvider: CoreCourseProvider) {
this.logger = logger.getInstance('AddonCalendarHelperProvider'); this.logger = logger.getInstance('AddonCalendarHelperProvider');
} }

@ -14,6 +14,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { CoreUtilsProvider } from '../../../../providers/utils/utils';
/** /**
* Directive to render a checkbox user profile field. * Directive to render a checkbox user profile field.
@ -28,7 +29,7 @@ export class AddonUserProfileFieldCheckboxComponent implements OnInit {
@Input() disabled?: boolean = false; // True if disabled. Defaults to false. @Input() disabled?: boolean = false; // True if disabled. Defaults to false.
@Input() form?: FormGroup; // Form where to add the form control. @Input() form?: FormGroup; // Form where to add the form control.
constructor(private fb: FormBuilder) {} constructor(private fb: FormBuilder, protected utils: CoreUtilsProvider) {}
/** /**
* Component being initialized. * Component being initialized.
@ -41,10 +42,11 @@ export class AddonUserProfileFieldCheckboxComponent implements OnInit {
// Initialize the value. // Initialize the value.
let formData = { let formData = {
value: field.defaultdata && field.defaultdata !== '0' && field.defaultdata !== 'false', value: this.utils.isTrueOrOne(field.defaultdata),
disabled: this.disabled disabled: this.disabled
}; };
this.form.addControl(field.modelName, this.fb.control(formData, field.required && !field.locked ? Validators.requiredTrue : null)); this.form.addControl(field.modelName, this.fb.control(formData,
field.required && !field.locked ? Validators.requiredTrue : null));
} }
} }

@ -13,7 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '../../../../core/user/providers/user-profile-field-delegate'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from
'../../../../core/user/providers/user-profile-field-delegate';
import { AddonUserProfileFieldCheckboxComponent } from '../component/checkbox'; import { AddonUserProfileFieldCheckboxComponent } from '../component/checkbox';
/** /**

@ -15,6 +15,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { CoreTimeUtilsProvider } from '../../../../providers/utils/time'; import { CoreTimeUtilsProvider } from '../../../../providers/utils/time';
import { CoreUtilsProvider } from '../../../../providers/utils/utils';
/** /**
* Directive to render a datetime user profile field. * Directive to render a datetime user profile field.
@ -29,7 +30,7 @@ export class AddonUserProfileFieldDatetimeComponent implements OnInit {
@Input() disabled?: boolean = false; // True if disabled. Defaults to false. @Input() disabled?: boolean = false; // True if disabled. Defaults to false.
@Input() form?: FormGroup; // Form where to add the form control. @Input() form?: FormGroup; // Form where to add the form control.
constructor(private fb: FormBuilder, private timeUtils: CoreTimeUtilsProvider) {} constructor(private fb: FormBuilder, private timeUtils: CoreTimeUtilsProvider, protected utils: CoreUtilsProvider) {}
/** /**
* Component being initialized. * Component being initialized.
@ -41,7 +42,7 @@ export class AddonUserProfileFieldDatetimeComponent implements OnInit {
field.modelName = 'profile_field_' + field.shortname; field.modelName = 'profile_field_' + field.shortname;
// Check if it's only date or it has time too. // Check if it's only date or it has time too.
let hasTime = field.param3 && field.param3 !== '0' && field.param3 !== 'false'; let hasTime = this.utils.isTrueOrOne(field.param3);
field.format = hasTime ? this.timeUtils.getLocalizedDateFormat('LLL') : this.timeUtils.getLocalizedDateFormat('LL'); field.format = hasTime ? this.timeUtils.getLocalizedDateFormat('LLL') : this.timeUtils.getLocalizedDateFormat('LL');
// Check min value. // Check min value.
@ -64,7 +65,8 @@ export class AddonUserProfileFieldDatetimeComponent implements OnInit {
value: field.defaultdata, value: field.defaultdata,
disabled: this.disabled disabled: this.disabled
}; };
this.form.addControl(field.modelName, this.fb.control(formData, field.required && !field.locked ? Validators.required : null)); this.form.addControl(field.modelName, this.fb.control(formData,
field.required && !field.locked ? Validators.required : null));
} }
} }

@ -13,9 +13,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '../../../../core/user/providers/user-profile-field-delegate'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from
'../../../../core/user/providers/user-profile-field-delegate';
import { AddonUserProfileFieldDatetimeComponent } from '../component/datetime'; import { AddonUserProfileFieldDatetimeComponent } from '../component/datetime';
import { Platform } from 'ionic-angular';
/** /**
* Datetime user profile field handlers. * Datetime user profile field handlers.
@ -24,7 +24,7 @@ import { Platform } from 'ionic-angular';
export class AddonUserProfileFieldDatetimeHandler implements CoreUserProfileFieldHandler { export class AddonUserProfileFieldDatetimeHandler implements CoreUserProfileFieldHandler {
name = 'datetime'; name = 'datetime';
constructor(private platform: Platform) {} constructor() {}
/** /**
* Whether or not the handler is enabled on a site level. * Whether or not the handler is enabled on a site level.

@ -51,7 +51,8 @@ export class AddonUserProfileFieldMenuComponent implements OnInit {
disabled: this.disabled disabled: this.disabled
}; };
// Initialize the value using default data. // Initialize the value using default data.
this.form.addControl(field.modelName, this.fb.control(formData, field.required && !field.locked ? Validators.required : null)); this.form.addControl(field.modelName, this.fb.control(formData,
field.required && !field.locked ? Validators.required : null));
} }
} }

@ -13,7 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '../../../../core/user/providers/user-profile-field-delegate'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from
'../../../../core/user/providers/user-profile-field-delegate';
import { AddonUserProfileFieldMenuComponent } from '../component/menu'; import { AddonUserProfileFieldMenuComponent } from '../component/menu';
/** /**

@ -14,6 +14,7 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { CoreUtilsProvider } from '../../../../providers/utils/utils';
/** /**
* Directive to render a text user profile field. * Directive to render a text user profile field.
@ -28,7 +29,7 @@ export class AddonUserProfileFieldTextComponent implements OnInit {
@Input() disabled?: boolean = false; // True if disabled. Defaults to false. @Input() disabled?: boolean = false; // True if disabled. Defaults to false.
@Input() form?: FormGroup; // Form where to add the form control. @Input() form?: FormGroup; // Form where to add the form control.
constructor(private fb: FormBuilder) {} constructor(private fb: FormBuilder, protected utils: CoreUtilsProvider) {}
/** /**
* Component being initialized. * Component being initialized.
@ -45,14 +46,15 @@ export class AddonUserProfileFieldTextComponent implements OnInit {
} }
// Check if it's a password or text. // Check if it's a password or text.
field.inputType = field.param3 && field.param3 !== '0' && field.param3 !== 'false' ? 'password' : 'text'; field.inputType = this.utils.isTrueOrOne(field.param3) ? 'password' : 'text';
let formData = { let formData = {
value: field.defaultdata, value: field.defaultdata,
disabled: this.disabled disabled: this.disabled
}; };
// Initialize the value using default data. // Initialize the value using default data.
this.form.addControl(field.modelName, this.fb.control(formData, field.required && !field.locked ? Validators.required : null)); this.form.addControl(field.modelName, this.fb.control(formData,
field.required && !field.locked ? Validators.required : null));
} }
} }

@ -13,7 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '../../../../core/user/providers/user-profile-field-delegate'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from
'../../../../core/user/providers/user-profile-field-delegate';
import { AddonUserProfileFieldTextComponent } from '../component/text'; import { AddonUserProfileFieldTextComponent } from '../component/text';
import { CoreTextUtilsProvider } from '../../../../providers/utils/text'; import { CoreTextUtilsProvider } from '../../../../providers/utils/text';

@ -40,7 +40,6 @@ export class AddonUserProfileFieldTextareaComponent implements OnInit {
if (field && this.edit && this.form) { if (field && this.edit && this.form) {
field.modelName = 'profile_field_' + field.shortname; field.modelName = 'profile_field_' + field.shortname;
}
let formData = { let formData = {
value: field.defaultdata, value: field.defaultdata,
@ -50,5 +49,6 @@ export class AddonUserProfileFieldTextareaComponent implements OnInit {
this.control = new FormControl(formData, field.required && !field.locked ? Validators.required : null); this.control = new FormControl(formData, field.required && !field.locked ? Validators.required : null);
this.form.addControl(field.modelName, this.control); this.form.addControl(field.modelName, this.control);
} }
}
} }

@ -13,7 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '../../../../core/user/providers/user-profile-field-delegate'; import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from
'../../../../core/user/providers/user-profile-field-delegate';
import { AddonUserProfileFieldTextareaComponent } from '../component/textarea'; import { AddonUserProfileFieldTextareaComponent } from '../component/textarea';
import { CoreTextUtilsProvider } from '../../../../providers/utils/text'; import { CoreTextUtilsProvider } from '../../../../providers/utils/text';

@ -39,7 +39,7 @@ export class CoreDelegate {
/** /**
* Logger instance get from CoreLoggerProvider. * Logger instance get from CoreLoggerProvider.
* @type {function} * @type {any}
*/ */
protected logger; protected logger;
@ -84,7 +84,6 @@ export class CoreDelegate {
constructor(delegateName: string, protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, constructor(delegateName: string, protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider,
protected eventsProvider: CoreEventsProvider) { protected eventsProvider: CoreEventsProvider) {
this.logger = this.loggerProvider.getInstance(delegateName); this.logger = this.loggerProvider.getInstance(delegateName);
this.sitesProvider = sitesProvider;
// Update handlers on this cases. // Update handlers on this cases.
eventsProvider.on(CoreEventsProvider.LOGIN, this.updateHandlers.bind(this)); eventsProvider.on(CoreEventsProvider.LOGIN, this.updateHandlers.bind(this));
@ -151,7 +150,7 @@ export class CoreDelegate {
* *
* @param {string} name The handler name. * @param {string} name The handler name.
* @param {boolean} [enabled] Only enabled, or any. * @param {boolean} [enabled] Only enabled, or any.
* @return {boolean} If the controller is installed or not. * @return {boolean} If the handler is registered or not.
*/ */
hasHandler(name: string, enabled = false): boolean { hasHandler(name: string, enabled = false): boolean {
return enabled ? typeof this.enabledHandlers[name] !== 'undefined' : typeof this.handlers[name] !== 'undefined'; return enabled ? typeof this.enabledHandlers[name] !== 'undefined' : typeof this.handlers[name] !== 'undefined';
@ -172,9 +171,12 @@ export class CoreDelegate {
} }
/** /**
* Register a profile handler. * Register a handler.
*
* @param {CoreDelegateHandler} handler The handler delegate object to register.
* @return {boolean} True when registered, false if already registered.
*/ */
registerHandler(handler: CoreDelegateHandler) { registerHandler(handler: CoreDelegateHandler): boolean {
if (typeof this.handlers[handler.name] !== 'undefined') { if (typeof this.handlers[handler.name] !== 'undefined') {
this.logger.log(`Addon '${handler.name}' already registered`); this.logger.log(`Addon '${handler.name}' already registered`);
return false; return false;

@ -26,7 +26,7 @@ export class CoreCoursePickerMenuPopoverComponent {
courses: any[]; courses: any[];
courseId = -1; courseId = -1;
constructor(private navParams: NavParams, private viewCtrl: ViewController) { constructor(navParams: NavParams, private viewCtrl: ViewController) {
this.courses = navParams.get('courses') || []; this.courses = navParams.get('courses') || [];
this.courseId = navParams.get('courseId') || -1; this.courseId = navParams.get('courseId') || -1;
} }

@ -29,8 +29,7 @@ import { Keyboard } from '@ionic-native/keyboard';
* could be easily broken. * could be easily broken.
* *
* Example: * Example:
* <core-rich-text-editor model="newpost" placeholder="{{ 'mma.mod_forum.message' | translate }}" scroll-handle="mmaScrollHandle"> * <core-rich-text-editor item-content [control]="control" [placeholder]="field.name"></core-rich-text-editor>
* </core-rich-text-editor>
* *
* In the example above, the text written in the editor will be stored in newpost.text. * In the example above, the text written in the editor will be stored in newpost.text.
*/ */

@ -14,9 +14,8 @@
// Code based on https://github.com/martinpritchardelevate/ionic-split-pane-demo // Code based on https://github.com/martinpritchardelevate/ionic-split-pane-demo
import { Component, ViewChild, Injectable, Input, ElementRef, OnInit } from '@angular/core'; import { Component, ViewChild, Input, ElementRef, OnInit } from '@angular/core';
import { NavController, Nav } from 'ionic-angular'; import { NavController, Nav } from 'ionic-angular';
import { CoreSplitViewPlaceholderPage } from './placeholder/placeholder';
/** /**
* Directive to create a split view layout. * Directive to create a split view layout.

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input, Output, OnInit, OnDestroy, ElementRef, EventEmitter, ContentChild, TemplateRef, import { Component, Input, Output, OnInit, OnDestroy, ElementRef, EventEmitter, ContentChild, TemplateRef } from '@angular/core';
ViewChild } from '@angular/core';
import { CoreTabsComponent } from './tabs'; import { CoreTabsComponent } from './tabs';
import { Content } from 'ionic-angular'; import { Content } from 'ionic-angular';

@ -72,7 +72,7 @@ export class CoreContentLinksHelperProvider {
*/ */
goInSite(navCtrl: NavController, pageName: string, pageParams: any, siteId?: string) : void { goInSite(navCtrl: NavController, pageName: string, pageParams: any, siteId?: string) : void {
siteId = siteId || this.sitesProvider.getCurrentSiteId(); siteId = siteId || this.sitesProvider.getCurrentSiteId();
if (siteId == this.sitesProvider.getCurrentSiteId()) { if (navCtrl && siteId == this.sitesProvider.getCurrentSiteId()) {
navCtrl.push(pageName, pageParams); navCtrl.push(pageName, pageParams);
} else { } else {
this.loginHelper.redirect(pageName, pageParams, siteId); this.loginHelper.redirect(pageName, pageParams, siteId);

@ -13,9 +13,6 @@
// limitations under the License. // limitations under the License.
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { IonicPage, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreTextUtilsProvider } from '../../../../providers/utils/text';
import { CoreCourseProvider } from '../../providers/course'; import { CoreCourseProvider } from '../../providers/course';
import { CoreCourseModuleDelegate } from '../../providers/module-delegate'; import { CoreCourseModuleDelegate } from '../../providers/module-delegate';
@ -34,8 +31,7 @@ export class CoreCourseUnsupportedModuleComponent implements OnInit {
isSupportedByTheApp: boolean; isSupportedByTheApp: boolean;
moduleName: string; moduleName: string;
constructor(navParams: NavParams, private translate: TranslateService, private textUtils: CoreTextUtilsProvider, constructor(private courseProvider: CoreCourseProvider, private moduleDelegate: CoreCourseModuleDelegate) {}
private courseProvider: CoreCourseProvider, private moduleDelegate: CoreCourseModuleDelegate) {}
/** /**
* Component being initialized. * Component being initialized.

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { IonicPage, NavParams, NavController } from 'ionic-angular'; import { IonicPage, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreTextUtilsProvider } from '../../../../providers/utils/text'; import { CoreTextUtilsProvider } from '../../../../providers/utils/text';
@ -28,8 +28,7 @@ import { CoreTextUtilsProvider } from '../../../../providers/utils/text';
export class CoreCourseUnsupportedModulePage { export class CoreCourseUnsupportedModulePage {
module: any; module: any;
constructor(navParams: NavParams, private translate: TranslateService, private textUtils: CoreTextUtilsProvider, constructor(navParams: NavParams, private translate: TranslateService, private textUtils: CoreTextUtilsProvider) {
private navCtrl: NavController) {
this.module = navParams.get('module') || {}; this.module = navParams.get('module') || {};
} }

@ -25,7 +25,7 @@ import { CoreCoursesDelegate, CoreCoursesHandlerToDisplay } from '../../courses/
import { CoreSiteHomeProvider } from '../../sitehome/providers/sitehome'; import { CoreSiteHomeProvider } from '../../sitehome/providers/sitehome';
import { CoreCourseProvider } from './course'; import { CoreCourseProvider } from './course';
import { CoreCourseModuleDelegate } from './module-delegate'; import { CoreCourseModuleDelegate } from './module-delegate';
import { CoreCourseModulePrefetchDelegate, CoreCourseModulePrefetchHandler } from './module-prefetch-delegate'; import { CoreCourseModulePrefetchDelegate } from './module-prefetch-delegate';
import { CoreLoginHelperProvider } from '../../login/providers/helper'; import { CoreLoginHelperProvider } from '../../login/providers/helper';
import { CoreConstants } from '../../constants'; import { CoreConstants } from '../../constants';
import { CoreSite } from '../../../classes/site'; import { CoreSite } from '../../../classes/site';

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CoreEventsProvider } from '../../../providers/events'; import { CoreEventsProvider } from '../../../providers/events';
import { CoreFileProvider } from '../../../providers/file'; import { CoreFileProvider } from '../../../providers/file';
import { CoreFilepoolProvider } from '../../../providers/filepool'; import { CoreFilepoolProvider } from '../../../providers/filepool';
@ -957,8 +956,7 @@ export class CoreCourseModulePrefetchDelegate {
* @return {Promise<boolean>} Promise resolved with true if downloadable, false otherwise. * @return {Promise<boolean>} Promise resolved with true if downloadable, false otherwise.
*/ */
isModuleDownloadable(module: any, courseId: number) : Promise<boolean> { isModuleDownloadable(module: any, courseId: number) : Promise<boolean> {
let handler = this.getPrefetchHandlerFor(module), let handler = this.getPrefetchHandlerFor(module);
promise;
if (handler) { if (handler) {
if (typeof handler.isDownloadable == 'function') { if (typeof handler.isDownloadable == 'function') {

@ -31,7 +31,8 @@ import { CoreCoursesProvider } from '../../providers/courses';
export class CoreCoursesCourseListItemComponent implements OnInit { export class CoreCoursesCourseListItemComponent implements OnInit {
@Input() course: any; // The course to render. @Input() course: any; // The course to render.
constructor(private navCtrl: NavController, private translate: TranslateService, private coursesProvider: CoreCoursesProvider) {} constructor(private navCtrl: NavController, private translate: TranslateService, private coursesProvider: CoreCoursesProvider) {
}
/** /**
* Component being initialized. * Component being initialized.

@ -14,7 +14,6 @@
import { Component, Input, OnInit, OnDestroy } from '@angular/core'; import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { NavController } from 'ionic-angular'; import { NavController } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { CoreEventsProvider } from '../../../../providers/events'; import { CoreEventsProvider } from '../../../../providers/events';
import { CoreSitesProvider } from '../../../../providers/sites'; import { CoreSitesProvider } from '../../../../providers/sites';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom'; import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
@ -45,7 +44,7 @@ export class CoreCoursesCourseProgressComponent implements OnInit, OnDestroy {
protected isDestroyed = false; protected isDestroyed = false;
protected courseStatusObserver; protected courseStatusObserver;
constructor(private navCtrl: NavController, private translate: TranslateService, private courseHelper: CoreCourseHelperProvider, constructor(private navCtrl: NavController, private courseHelper: CoreCourseHelperProvider,
private courseFormatDelegate: CoreCourseFormatDelegate, private domUtils: CoreDomUtilsProvider, private courseFormatDelegate: CoreCourseFormatDelegate, private domUtils: CoreDomUtilsProvider,
private courseProvider: CoreCourseProvider, eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider) { private courseProvider: CoreCourseProvider, eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider) {
// Listen for status change in course. // Listen for status change in course.

@ -16,7 +16,6 @@ import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '../../contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '../../contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '../../contentlinks/providers/delegate'; import { CoreContentLinksAction } from '../../contentlinks/providers/delegate';
import { CoreLoginHelperProvider } from '../../login/providers/helper'; import { CoreLoginHelperProvider } from '../../login/providers/helper';
import { CoreCoursesProvider } from './courses';
/** /**
* Handler to treat links to my overview. * Handler to treat links to my overview.
@ -27,7 +26,7 @@ export class CoreCoursesMyOverviewLinkHandler extends CoreContentLinksHandlerBas
featureName = '$mmSideMenuDelegate_mmCourses'; featureName = '$mmSideMenuDelegate_mmCourses';
pattern = /\/my\/?$/; pattern = /\/my\/?$/;
constructor(private coursesProvider: CoreCoursesProvider, private loginHelper: CoreLoginHelperProvider) { constructor(private loginHelper: CoreLoginHelperProvider) {
super(); super();
} }

@ -384,7 +384,8 @@ export class FileMock extends File {
* @param {string} dirName The source directory name. * @param {string} dirName The source directory name.
* @param {string} newPath The destionation path to the directory. * @param {string} newPath The destionation path to the directory.
* @param {string} newDirName The destination directory name. * @param {string} newDirName The destination directory name.
* @returns {Promise<DirectoryEntry|Entry>} Returns a Promise that resolves to the new DirectoryEntry object or rejects with an error. * @returns {Promise<DirectoryEntry|Entry>} Returns a Promise that resolves to the new DirectoryEntry object or rejects with
* an error.
*/ */
moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<DirectoryEntry | Entry> { moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<DirectoryEntry | Entry> {
return this.resolveDirectoryUrl(path).then((fse) => { return this.resolveDirectoryUrl(path).then((fse) => {
@ -421,7 +422,8 @@ export class FileMock extends File {
* Read file and return data as an ArrayBuffer. * Read file and return data as an ArrayBuffer.
* @param {string} path Base FileSystem. * @param {string} path Base FileSystem.
* @param {string} file Name of file, relative to path. * @param {string} file Name of file, relative to path.
* @returns {Promise<ArrayBuffer>} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects with an error. * @returns {Promise<ArrayBuffer>} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects
* with an error.
*/ */
readAsArrayBuffer(path: string, file: string): Promise<ArrayBuffer> { readAsArrayBuffer(path: string, file: string): Promise<ArrayBuffer> {
return this.readFileMock<ArrayBuffer>(path, file, 'ArrayBuffer'); return this.readFileMock<ArrayBuffer>(path, file, 'ArrayBuffer');
@ -444,7 +446,8 @@ export class FileMock extends File {
* @param {string} path Base FileSystem. * @param {string} path Base FileSystem.
* @param {string} file Name of file, relative to path. * @param {string} file Name of file, relative to path.
* @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as data URL or rejects with an error. * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as data URL or rejects
* with an error.
*/ */
readAsDataURL(path: string, file: string): Promise<string> { readAsDataURL(path: string, file: string): Promise<string> {
return this.readFileMock<string>(path, file, 'DataURL'); return this.readFileMock<string>(path, file, 'DataURL');

@ -712,7 +712,8 @@ export class LocalNotificationsMock extends LocalNotifications {
let tileNotif = new this.winNotif.TileNotification({ let tileNotif = new this.winNotif.TileNotification({
tag: notification.id + '', tag: notification.id + '',
template: this.tileTemplate, template: this.tileTemplate,
strings: [notification.title, notification.text, notification.title, notification.text, notification.title, notification.text], strings: [notification.title, notification.text, notification.title, notification.text, notification.title,
notification.text],
expirationTime: new Date(Date.now() + CoreConstants.SECONDS_HOUR * 1000) // Expire in 1 hour. expirationTime: new Date(Date.now() + CoreConstants.SECONDS_HOUR * 1000) // Expire in 1 hour.
}) })

@ -65,7 +65,8 @@ export class CoreFileUploaderHelperProvider {
} }
wifiThreshold = typeof wifiThreshold == 'undefined' ? CoreFileUploaderProvider.WIFI_SIZE_WARNING : wifiThreshold; wifiThreshold = typeof wifiThreshold == 'undefined' ? CoreFileUploaderProvider.WIFI_SIZE_WARNING : wifiThreshold;
limitedThreshold = typeof limitedThreshold == 'undefined' ? CoreFileUploaderProvider.LIMITED_SIZE_WARNING : limitedThreshold; limitedThreshold = typeof limitedThreshold == 'undefined' ?
CoreFileUploaderProvider.LIMITED_SIZE_WARNING : limitedThreshold;
if (size < 0) { if (size < 0) {
return this.domUtils.showConfirm(this.translate.instant('core.fileuploader.confirmuploadunknownsize')); return this.domUtils.showConfirm(this.translate.instant('core.fileuploader.confirmuploadunknownsize'));

@ -229,7 +229,8 @@ export class CoreLoginEmailSignupPage {
} }
// Get the data for the custom profile fields. // Get the data for the custom profile fields.
this.userProfileFieldDelegate.getDataForFields(this.settings.profilefields, true, 'email', this.signupForm.value).then((fieldsData) => { this.userProfileFieldDelegate.getDataForFields(this.settings.profilefields, true, 'email', this.signupForm.value).then(
(fieldsData) => {
params.customprofilefields = fieldsData; params.customprofilefields = fieldsData;
this.wsProvider.callAjax('auth_email_signup_user', params, {siteUrl: this.siteUrl}).then((result) => { this.wsProvider.callAjax('auth_email_signup_user', params, {siteUrl: this.siteUrl}).then((result) => {

@ -88,7 +88,7 @@ export class CoreMainMenuDelegate extends CoreDelegate {
protected handlers: {[s: string]: CoreMainMenuHandler} = {}; protected handlers: {[s: string]: CoreMainMenuHandler} = {};
protected enabledHandlers: {[s: string]: CoreMainMenuHandler} = {}; protected enabledHandlers: {[s: string]: CoreMainMenuHandler} = {};
protected loaded = false; protected loaded = false;
protected siteHandlers: Subject<CoreMainMenuHandlerToDisplay[]> = new BehaviorSubject<CoreMainMenuHandlerData[]>([]); protected siteHandlers: Subject<CoreMainMenuHandlerToDisplay[]> = new BehaviorSubject<CoreMainMenuHandlerToDisplay[]>([]);
protected featurePrefix = '$mmSideMenuDelegate_'; protected featurePrefix = '$mmSideMenuDelegate_';
constructor(protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, constructor(protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider,

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input } from '@angular/core'; import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { CoreCoursesProvider } from '../../../courses/providers/courses'; import { CoreCoursesProvider } from '../../../courses/providers/courses';
/** /**

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input } from '@angular/core'; import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { CoreCoursesProvider } from '../../../courses/providers/courses'; import { CoreCoursesProvider } from '../../../courses/providers/courses';
/** /**

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input } from '@angular/core'; import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { CoreCoursesProvider } from '../../../courses/providers/courses'; import { CoreCoursesProvider } from '../../../courses/providers/courses';
/** /**

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { CoreCoursesProvider } from '../../../courses/providers/courses'; import { CoreCoursesProvider } from '../../../courses/providers/courses';
/** /**

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { CoreSitesProvider } from '../../../../providers/sites'; import { CoreSitesProvider } from '../../../../providers/sites';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom'; import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreCourseProvider } from '../../../course/providers/course'; import { CoreCourseProvider } from '../../../course/providers/course';

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { IonicPage } from 'ionic-angular';
import { CoreSitesProvider } from '../../../../providers/sites'; import { CoreSitesProvider } from '../../../../providers/sites';
/** /**

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { Component, Input, ViewChild, ViewContainerRef, ComponentFactoryResolver, ComponentRef, OnInit } from '@angular/core'; import { Component, Input, ViewChild, ViewContainerRef, ComponentFactoryResolver, OnInit } from '@angular/core';
import { CoreLoggerProvider } from '../../../../providers/logger'; import { CoreLoggerProvider } from '../../../../providers/logger';
import { CoreUserProfileFieldDelegate } from '../../providers/user-profile-field-delegate'; import { CoreUserProfileFieldDelegate } from '../../providers/user-profile-field-delegate';
import { CoreUtilsProvider } from '../../../../providers/utils/utils'; import { CoreUtilsProvider } from '../../../../providers/utils/utils';

@ -7,7 +7,7 @@
<ion-refresher [enabled]="userLoaded" (ionRefresh)="refreshUser($event)"> <ion-refresher [enabled]="userLoaded" (ionRefresh)="refreshUser($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher> </ion-refresher>
<core-loading [hideUntil]="userLoaded" class="core-loading-center"> <core-loading [hideUntil]="userLoaded">
<div *ngIf="user"> <div *ngIf="user">
<ion-item-group *ngIf="hasContact"> <ion-item-group *ngIf="hasContact">
<ion-item-divider color="light">{{ 'core.user.contact' | translate}}</ion-item-divider> <ion-item-divider color="light">{{ 'core.user.contact' | translate}}</ion-item-divider>
@ -36,7 +36,8 @@
</a> </a>
<a *ngIf="!isAndroid" href="http://maps.google.com?q={{user.encodedAddress}}" core-link auto-login="no"> <a *ngIf="!isAndroid" href="http://maps.google.com?q={{user.encodedAddress}}" core-link auto-login="no">
<core-format-text [text]="user.address"></core-format-text> <core-format-text [text]="user.address"></core-format-text>
</a></p> </a>
</p>
</ion-item> </ion-item>
<ion-item text-wrap *ngIf="user.city && !user.address"> <ion-item text-wrap *ngIf="user.city && !user.address">
<h2>{{ 'core.user.city' | translate}}</h2> <h2>{{ 'core.user.city' | translate}}</h2>

@ -17,7 +17,6 @@ import { IonicPage, NavParams, Platform } from 'ionic-angular';
import { CoreUserProvider } from '../../providers/user'; import { CoreUserProvider } from '../../providers/user';
import { CoreUserHelperProvider } from '../../providers/helper'; import { CoreUserHelperProvider } from '../../providers/helper';
import { CoreDomUtilsProvider } from '../../../../providers/utils/dom'; import { CoreDomUtilsProvider } from '../../../../providers/utils/dom';
import { CoreCoursesProvider } from '../../../courses/providers/courses';
import { CoreEventsProvider } from '../../../../providers/events'; import { CoreEventsProvider } from '../../../../providers/events';
import { CoreSitesProvider } from '../../../../providers/sites'; import { CoreSitesProvider } from '../../../../providers/sites';
@ -41,7 +40,7 @@ export class CoreUserAboutPage {
user: any = {}; user: any = {};
title: string; title: string;
constructor(private navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider, constructor(navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider,
private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider, private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider,
private sitesProvider: CoreSitesProvider, private platform: Platform) { private sitesProvider: CoreSitesProvider, private platform: Platform) {

@ -7,7 +7,7 @@
<ion-refresher [enabled]="userLoaded" (ionRefresh)="refreshUser($event)"> <ion-refresher [enabled]="userLoaded" (ionRefresh)="refreshUser($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher> </ion-refresher>
<core-loading [hideUntil]="userLoaded" class="core-loading-center"> <core-loading [hideUntil]="userLoaded">
<ion-list *ngIf="user && !isDeleted"> <ion-list *ngIf="user && !isDeleted">
<ion-item text-center> <ion-item text-center>
<div class="item-avatar-center"> <div class="item-avatar-center">
@ -51,7 +51,7 @@
</a> </a>
<ion-item *ngIf="actionHandlers && actionHandlers.length"> <ion-item *ngIf="actionHandlers && actionHandlers.length">
<button *ngFor="let actHandler of actionHandlers" ion-button block outline [ngClass]="['core-user-profile-handler', actHandler.class]" (click)="actHandler.action($event)" [hidden]="actHandler.hidden" title="{{ actHandler.title | translate }}"> <button *ngFor="let actHandler of actionHandlers" ion-button block outline [ngClass]="['core-user-profile-handler', actHandler.class]" (click)="actHandler.action($event, user, courseId)" [hidden]="actHandler.hidden" title="{{ actHandler.title | translate }}">
<ion-icon *ngIf="actHandler.icon" [name]="actHandler.icon" item-start></ion-icon> <ion-icon *ngIf="actHandler.icon" [name]="actHandler.icon" item-start></ion-icon>
{{ actHandler.title | translate }} {{ actHandler.title | translate }}
<ion-spinner *ngIf="actHandler.spinner" item-end></ion-spinner> <ion-spinner *ngIf="actHandler.spinner" item-end></ion-spinner>

@ -49,7 +49,7 @@ export class CoreUserProfilePage {
newPageHandlers = []; newPageHandlers = [];
communicationHandlers = []; communicationHandlers = [];
constructor(private navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider, constructor(navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider,
private domUtils: CoreDomUtilsProvider, private translate: TranslateService, private eventsProvider: CoreEventsProvider, private domUtils: CoreDomUtilsProvider, private translate: TranslateService, private eventsProvider: CoreEventsProvider,
private coursesProvider: CoreCoursesProvider, private sitesProvider: CoreSitesProvider, private coursesProvider: CoreCoursesProvider, private sitesProvider: CoreSitesProvider,
private mimetypeUtils: CoreMimetypeUtilsProvider, private fileUploaderHelper: CoreFileUploaderHelperProvider, private mimetypeUtils: CoreMimetypeUtilsProvider, private fileUploaderHelper: CoreFileUploaderHelperProvider,
@ -81,7 +81,7 @@ export class CoreUserProfilePage {
ionViewDidLoad() { ionViewDidLoad() {
this.fetchUser().then(() => { this.fetchUser().then(() => {
return this.userProvider.logView(this.userId, this.courseId).catch((error) => { return this.userProvider.logView(this.userId, this.courseId).catch((error) => {
this.isDeleted = error === this.translate.instant('core.userdeleted'); this.isDeleted = error.errorcode === 'userdeleted';
}); });
}).finally(() => { }).finally(() => {
this.userLoaded = true; this.userLoaded = true;
@ -142,10 +142,11 @@ export class CoreUserProfilePage {
let modal = this.domUtils.showModalLoading('core.sending', true); let modal = this.domUtils.showModalLoading('core.sending', true);
return this.userProvider.changeProfilePicture(result.itemid, this.userId).then((profileImageURL) => { return this.userProvider.changeProfilePicture(result.itemid, this.userId).then((profileImageURL) => {
this.eventsProvider.trigger(CoreUserProvider.PROFILE_PICTURE_UPDATED, {userId: this.userId, picture: profileImageURL}); this.eventsProvider.trigger(CoreUserProvider.PROFILE_PICTURE_UPDATED, {userId: this.userId,
picture: profileImageURL});
this.sitesProvider.updateSiteInfo(this.site.getId()); this.sitesProvider.updateSiteInfo(this.site.getId());
this.refreshUser(); this.refreshUser();
}).finally(function() { }).finally(() => {
modal.dismiss(); modal.dismiss();
}); });
}).catch((message) => { }).catch((message) => {

@ -72,7 +72,7 @@ export interface CoreUserProfileHandlerData {
* Additional class to add to the HTML. * Additional class to add to the HTML.
* @type {string} * @type {string}
*/ */
class: string; class?: string;
/** /**
* If enabled, element will be hidden. Only for TYPE_NEW_PAGE and TYPE_ACTION. * If enabled, element will be hidden. Only for TYPE_NEW_PAGE and TYPE_ACTION.
@ -135,7 +135,7 @@ export class CoreUserDelegate extends CoreDelegate {
* @param {number} courseId The course ID. * @param {number} courseId The course ID.
* @return {Promise<any>} Resolved with an array of objects containing 'priority', 'data' and 'type'. * @return {Promise<any>} Resolved with an array of objects containing 'priority', 'data' and 'type'.
*/ */
getProfileHandlersFor(user: any, courseId): Promise<any> { getProfileHandlersFor(user: any, courseId: number): Promise<any> {
let handlers = [], let handlers = [],
promises = []; promises = [];
@ -147,7 +147,7 @@ export class CoreUserDelegate extends CoreDelegate {
return this.coursesProvider.getCoursesOptions(courseIds).then((options) => { return this.coursesProvider.getCoursesOptions(courseIds).then((options) => {
// For backwards compatibility we don't modify the courseId. // For backwards compatibility we don't modify the courseId.
let courseIdForOptions = courseId || this.sitesProvider.getSiteHomeId(), let courseIdForOptions = courseId || this.sitesProvider.getCurrentSiteHomeId(),
navOptions = options.navOptions[courseIdForOptions], navOptions = options.navOptions[courseIdForOptions],
admOptions = options.admOptions[courseIdForOptions]; admOptions = options.admOptions[courseIdForOptions];
@ -165,7 +165,7 @@ export class CoreUserDelegate extends CoreDelegate {
} else { } else {
return Promise.reject(null); return Promise.reject(null);
} }
}).catch(function() { }).catch(() => {
// Nothing to do here, it is not enabled for this user. // Nothing to do here, it is not enabled for this user.
}); });
promises.push(promise); promises.push(promise);
@ -175,7 +175,7 @@ export class CoreUserDelegate extends CoreDelegate {
return handlers; return handlers;
}); });
}); });
}).catch(function() { }).catch(() => {
// Never fails. // Never fails.
return handlers; return handlers;
}); });

@ -63,7 +63,7 @@ export class CoreUserProfileMailHandler implements CoreUserProfileHandler {
action: ($event, user, courseId) => { action: ($event, user, courseId) => {
$event.preventDefault(); $event.preventDefault();
$event.stopPropagation(); $event.stopPropagation();
window.location.href = "mailto:" + user.email; window.open("mailto:" + user.email, '_blank');
} }
}; };
} }

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreContentLinksHandlerBase } from '../../contentlinks/classes/base-handler'; import { CoreContentLinksHandlerBase } from '../../contentlinks/classes/base-handler';
import { CoreContentLinksAction } from '../../contentlinks/providers/delegate'; import { CoreContentLinksAction } from '../../contentlinks/providers/delegate';
import { CoreLoginHelperProvider } from '../../login/providers/helper'; import { CoreContentLinksHelperProvider } from '../../contentlinks/providers/helper';
/** /**
* Handler to treat links to user profiles. * Handler to treat links to user profiles.
@ -26,7 +26,7 @@ export class CoreUserProfileLinkHandler extends CoreContentLinksHandlerBase {
// Match user/view.php and user/profile.php but NOT grade/report/user/. // Match user/view.php and user/profile.php but NOT grade/report/user/.
pattern = /((\/user\/view\.php)|(\/user\/profile\.php)).*([\?\&]id=\d+)/; pattern = /((\/user\/view\.php)|(\/user\/profile\.php)).*([\?\&]id=\d+)/;
constructor(private loginHelper: CoreLoginHelperProvider) { constructor(private linkHelper: CoreContentLinksHelperProvider) {
super(); super();
} }
@ -43,12 +43,12 @@ export class CoreUserProfileLinkHandler extends CoreContentLinksHandlerBase {
CoreContentLinksAction[]|Promise<CoreContentLinksAction[]> { CoreContentLinksAction[]|Promise<CoreContentLinksAction[]> {
return [{ return [{
action: (siteId, navCtrl?) => { action: (siteId, navCtrl?) => {
let stateParams = { let pageParams = {
courseId: params.course, courseId: params.course,
userId: parseInt(params.id, 10) userId: parseInt(params.id, 10)
}; };
// Always use redirect to make it the new history root (to avoid "loops" in history). // Always use redirect to make it the new history root (to avoid "loops" in history).
this.loginHelper.redirect('CoreUserProfilePage', stateParams, siteId); this.linkHelper.goInSite(navCtrl, 'CoreUserProfilePage', pageParams, siteId);
} }
}]; }];
} }

@ -61,10 +61,10 @@ export class CoreUserProvider {
* Change the given user profile picture. * Change the given user profile picture.
* *
* @param {number} draftItemId New picture draft item id. * @param {number} draftItemId New picture draft item id.
* @param {number} id User ID. * @param {number} userId User ID.
* @return {Promise<any>} Promise resolve with the new profileimageurl * @return {Promise<string>} Promise resolve with the new profileimageurl
*/ */
changeProfilePicture(draftItemId: number, userId: number): Promise<any> { changeProfilePicture(draftItemId: number, userId: number): Promise<string> {
var data = { var data = {
'draftitemid': draftItemId, 'draftitemid': draftItemId,
'delete': 0, 'delete': 0,
@ -83,7 +83,7 @@ export class CoreUserProvider {
* Store user basic information in local DB to be retrieved if the WS call fails. * Store user basic information in local DB to be retrieved if the WS call fails.
* *
* @param {number} userId User ID. * @param {number} userId User ID.
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site. * @param {string} [siteId] ID of the site. If not defined, use current site.
* @return {Promise<any>} Promise resolve when the user is deleted. * @return {Promise<any>} Promise resolve when the user is deleted.
*/ */
deleteStoredUser(userId: number, siteId?: string): Promise<any> { deleteStoredUser(userId: number, siteId?: string): Promise<any> {
@ -111,24 +111,24 @@ export class CoreUserProvider {
* @param {number} userId User's ID. * @param {number} userId User's ID.
* @param {number} [courseId] Course ID to get course profile, undefined or 0 to get site profile. * @param {number} [courseId] Course ID to get course profile, undefined or 0 to get site profile.
* @param {boolean} [forceLocal] True to retrieve the user data from local DB, false to retrieve it from WS. * @param {boolean} [forceLocal] True to retrieve the user data from local DB, false to retrieve it from WS.
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site. * @param {string} [siteId] ID of the site. If not defined, use current site.
* @return {Promise<any>} Promise resolved with the user data. * @return {Promise<any>} Promise resolved with the user data.
*/ */
getProfile(userId: number, courseId: number, forceLocal = false, siteId?: string): Promise<any> { getProfile(userId: number, courseId?: number, forceLocal = false, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId(); siteId = siteId || this.sitesProvider.getCurrentSiteId();
if (forceLocal) { if (forceLocal) {
return this.getUserFromLocalDb(userId, siteId).catch(function() { return this.getUserFromLocalDb(userId, siteId).catch(() => {
return this.getUserFromWS(userId, courseId, siteId); return this.getUserFromWS(userId, courseId, siteId);
}); });
} }
return this.getUserFromWS(userId, courseId, siteId).catch(function() { return this.getUserFromWS(userId, courseId, siteId).catch(() => {
return this.getUserFromLocalDb(userId, siteId); return this.getUserFromLocalDb(userId, siteId);
}); });
} }
/** /**
* Invalidates user WS calls. * Get cache key for a user WS call.
* *
* @param {number} userId User ID. * @param {number} userId User ID.
* @return {string} Cache key. * @return {string} Cache key.
@ -141,7 +141,7 @@ export class CoreUserProvider {
* Get user basic information from local DB. * Get user basic information from local DB.
* *
* @param {number} userId User ID. * @param {number} userId User ID.
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site. * @param {string} [siteId] ID of the site. If not defined, use current site.
* @return {Promise<any>} Promise resolve when the user is retrieved. * @return {Promise<any>} Promise resolve when the user is retrieved.
*/ */
protected getUserFromLocalDb(userId: number, siteId?: string): Promise<any> { protected getUserFromLocalDb(userId: number, siteId?: string): Promise<any> {
@ -158,7 +158,7 @@ export class CoreUserProvider {
* @param {string} [siteId] ID of the site. If not defined, use current site. * @param {string} [siteId] ID of the site. If not defined, use current site.
* @return {Promise<any>} Promise resolve when the user is retrieved. * @return {Promise<any>} Promise resolve when the user is retrieved.
*/ */
protected getUserFromWS(userId: number, courseId: number, siteId?: string): Promise<any> { protected getUserFromWS(userId: number, courseId?: number, siteId?: string): Promise<any> {
return this.sitesProvider.getSite(siteId).then((site) => { return this.sitesProvider.getSite(siteId).then((site) => {
let presets = { let presets = {
cacheKey: this.getUserCacheKey(userId) cacheKey: this.getUserCacheKey(userId)
@ -226,14 +226,18 @@ export class CoreUserProvider {
/** /**
* Log User Profile View in Moodle. * Log User Profile View in Moodle.
* @param {number} userId User ID. * @param {number} userId User ID.
* @param {number} courseId Course ID. * @param {number} [courseId] Course ID.
* @return {Promise<any>} Promise resolved when done. * @return {Promise<any>} Promise resolved when done.
*/ */
logView(userId: number, courseId?: number) : Promise<any> { logView(userId: number, courseId?: number) : Promise<any> {
return this.sitesProvider.getCurrentSite().write('core_user_view_user_profile', { let params = {
userid: userId, userid: userId
courseid: courseId };
});
if (courseId) {
params['courseid'] = courseId;
}
return this.sitesProvider.getCurrentSite().write('core_user_view_user_profile', params);
} }
/** /**
@ -242,10 +246,10 @@ export class CoreUserProvider {
* @param {number} userId User ID. * @param {number} userId User ID.
* @param {string} fullname User full name. * @param {string} fullname User full name.
* @param {string} avatar User avatar URL. * @param {string} avatar User avatar URL.
* @param {string} [siteId] ID of the site the event belongs to. If not defined, use current site. * @param {string} [siteId] ID of the site. If not defined, use current site.
* @return {Promise<any>} Promise resolve when the user is stored. * @return {Promise<any>} Promise resolve when the user is stored.
*/ */
protected storeUser(userId: number, fullname: string, avatar: string, siteId?: string) { protected storeUser(userId: number, fullname: string, avatar: string, siteId?: string): Promise<any> {
return this.sitesProvider.getSite(siteId).then((site) => { return this.sitesProvider.getSite(siteId).then((site) => {
let userRecord = { let userRecord = {
id: userId, id: userId,

@ -46,7 +46,8 @@ export class CoreFormatTextDirective implements OnChanges {
@Input() componentId?: string|number; // Component ID to use in conjunction with the component. @Input() componentId?: string|number; // Component ID to use in conjunction with the component.
@Input() adaptImg?: boolean|string = true; // Whether to adapt images to screen width. @Input() adaptImg?: boolean|string = true; // Whether to adapt images to screen width.
@Input() clean?: boolean|string; // Whether all the HTML tags should be removed. @Input() clean?: boolean|string; // Whether all the HTML tags should be removed.
@Input() singleLine?: boolean|string; // Whether new lines should be removed (all text in single line). Only valid if clean=true. @Input() singleLine?: boolean|string; // Whether new lines should be removed (all text in single line). Only valid if
// clean=true.
@Input() maxHeight?: number; // Max height in pixels to render the content box. It should be 50 at least to make sense. @Input() maxHeight?: number; // Max height in pixels to render the content box. It should be 50 at least to make sense.
// Using this parameter will force display: block to calculate height better. If you want to // Using this parameter will force display: block to calculate height better. If you want to
// avoid this use class="inline" at the same time to use display: inline-block. // avoid this use class="inline" at the same time to use display: inline-block.
@ -253,7 +254,8 @@ export class CoreFormatTextDirective implements OnChanges {
site = siteInstance; site = siteInstance;
// Apply format text function. // Apply format text function.
return this.textUtils.formatText(this.text, this.utils.isTrueOrOne(this.clean), this.utils.isTrueOrOne(this.singleLine)); return this.textUtils.formatText(this.text, this.utils.isTrueOrOne(this.clean),
this.utils.isTrueOrOne(this.singleLine));
}).then((formatted) => { }).then((formatted) => {
let div = document.createElement('div'), let div = document.createElement('div'),
canTreatVimeo = site && site.isVersionGreaterEqualThan(['3.3.4', '3.4']), canTreatVimeo = site && site.isVersionGreaterEqualThan(['3.3.4', '3.4']),

@ -15,7 +15,7 @@
import { Directive, Input, OnInit, ElementRef } from '@angular/core'; import { Directive, Input, OnInit, ElementRef } from '@angular/core';
import { NavController } from 'ionic-angular'; import { NavController } from 'ionic-angular';
/** /**
* Directive to open a link in external browser. * Directive to go to user profile on click.
*/ */
@Directive({ @Directive({
selector: '[core-user-link]' selector: '[core-user-link]'

@ -664,6 +664,20 @@ export class CoreSitesProvider {
} }
} }
/**
* Get the site home ID of the current site.
*
* @return {number} Current site home ID.
*/
getCurrentSiteHomeId() : number {
if (this.currentSite) {
return this.currentSite.getSiteHomeId();
} else {
return 1;
}
}
/** /**
* Check if the user is logged in a site. * Check if the user is logged in a site.
* *

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { LoadingController, Loading, ToastController, Toast, AlertController, Alert, Platform, Content, import { LoadingController, Loading, ToastController, Toast, AlertController, Alert, Platform, Content,
NavController, ModalController } from 'ionic-angular'; ModalController } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreTextUtilsProvider } from './text'; import { CoreTextUtilsProvider } from './text';
import { CoreAppProvider } from '../app'; import { CoreAppProvider } from '../app';

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { NavController, ModalController } from 'ionic-angular'; import { ModalController } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { CoreLangProvider } from '../lang'; import { CoreLangProvider } from '../lang';

@ -144,7 +144,8 @@ export class CoreWSProvider {
* @param {string} siteUrl Complete site url to perform the call. * @param {string} siteUrl Complete site url to perform the call.
* @param {any} ajaxData Arguments to pass to the method. * @param {any} ajaxData Arguments to pass to the method.
* @param {CoreWSPreSets} preSets Extra settings and information. * @param {CoreWSPreSets} preSets Extra settings and information.
* @return {Promise<any>} Deferred promise resolved with the response data in success and rejected with the error message if it fails. * @return {Promise<any>} Deferred promise resolved with the response data in success and rejected with the error message
* if it fails.
*/ */
protected addToRetryQueue(method: string, siteUrl: string, ajaxData: any, preSets: CoreWSPreSets) : Promise<any> { protected addToRetryQueue(method: string, siteUrl: string, ajaxData: any, preSets: CoreWSPreSets) : Promise<any> {
let call = { let call = {