diff --git a/src/addon/badges/providers/mybadges-link-handler.ts b/src/addon/badges/providers/mybadges-link-handler.ts index 59a3025da..8c58e384d 100644 --- a/src/addon/badges/providers/mybadges-link-handler.ts +++ b/src/addon/badges/providers/mybadges-link-handler.ts @@ -24,7 +24,7 @@ import { AddonBadgesProvider } from './badges'; @Injectable() export class AddonBadgesMyBadgesLinkHandler extends CoreContentLinksHandlerBase { name = 'AddonBadgesMyBadgesLinkHandler'; - featureName = '$mmUserDelegate_mmaBadges'; + featureName = 'CoreUserDelegate_AddonBadges'; pattern = /\/badges\/mybadges\.php/; constructor(private badgesProvider: AddonBadgesProvider, private loginHelper: CoreLoginHelperProvider) { diff --git a/src/addon/badges/providers/user-handler.ts b/src/addon/badges/providers/user-handler.ts index 8e8ea9340..fb34cd633 100644 --- a/src/addon/badges/providers/user-handler.ts +++ b/src/addon/badges/providers/user-handler.ts @@ -21,7 +21,7 @@ import { AddonBadgesProvider } from './badges'; */ @Injectable() export class AddonBadgesUserHandler implements CoreUserProfileHandler { - name = 'mmaBadges'; + name = 'AddonBadges'; priority = 50; type = CoreUserDelegate.TYPE_NEW_PAGE; diff --git a/src/addon/calendar/providers/calendar.ts b/src/addon/calendar/providers/calendar.ts index 318800396..210923dae 100644 --- a/src/addon/calendar/providers/calendar.ts +++ b/src/addon/calendar/providers/calendar.ts @@ -343,7 +343,7 @@ export class AddonCalendarProvider { isCalendarDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmSideMenuDelegate_mmaCalendar'); + return site.isFeatureDisabled('CoreMainMenuDelegate_AddonCalendar'); } /** diff --git a/src/addon/competency/providers/user-handler.ts b/src/addon/competency/providers/user-handler.ts index ffc4a7c51..3b04349f6 100644 --- a/src/addon/competency/providers/user-handler.ts +++ b/src/addon/competency/providers/user-handler.ts @@ -25,7 +25,7 @@ import { AddonCompetencyProvider } from './competency'; */ @Injectable() export class AddonCompetencyUserHandler implements CoreUserProfileHandler { - name = 'AddonCompetency'; + name = 'AddonCompetency:learningPlan'; priority = 900; type = CoreUserDelegate.TYPE_NEW_PAGE; participantsNavEnabledCache = {}; @@ -58,8 +58,8 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler { * * @param {any} user User to check. * @param {number} courseId Course ID. - * @param {any} [navOptions] Course navigation options for current user. See $mmCourses#getUserNavigationOptions. - * @param {any} [admOptions] Course admin options for current user. See $mmCourses#getUserAdministrationOptions. + * @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. + * @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions. * @return {boolean|Promise} Promise resolved with true if enabled, resolved with false otherwise. */ isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { diff --git a/src/addon/files/providers/files.ts b/src/addon/files/providers/files.ts index 039241412..8cad3e251 100644 --- a/src/addon/files/providers/files.ts +++ b/src/addon/files/providers/files.ts @@ -295,7 +295,7 @@ export class AddonFilesProvider { isDisabledInSite(site: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmSideMenuDelegate_mmaFiles'); + return site.isFeatureDisabled('CoreMainMenuDelegate_AddonFiles'); } /** @@ -328,7 +328,7 @@ export class AddonFilesProvider { isPrivateFilesDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('files_privatefiles'); + return site.isFeatureDisabled('AddonFilesPrivateFiles'); } /** @@ -352,7 +352,7 @@ export class AddonFilesProvider { isSiteFilesDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('files_sitefiles'); + return site.isFeatureDisabled('AddonFilesSiteFiles'); } /** @@ -376,7 +376,7 @@ export class AddonFilesProvider { isUploadDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('files_upload'); + return site.isFeatureDisabled('AddonFilesUpload'); } /** diff --git a/src/addon/messages/messages.module.ts b/src/addon/messages/messages.module.ts index c05d03a90..31e009d6f 100644 --- a/src/addon/messages/messages.module.ts +++ b/src/addon/messages/messages.module.ts @@ -85,7 +85,7 @@ export class AddonMessagesModule { const notificationClicked = (notification: any): void => { messagesProvider.isMessagingEnabledForSite(notification.site).then(() => { - sitesProvider.isFeatureDisabled('$mmSideMenuDelegate_mmaMessages', notification.site).then((disabled) => { + sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonMessages', notification.site).then((disabled) => { if (disabled) { // Messages are disabled, stop. return; diff --git a/src/addon/messages/providers/user-add-contact-handler.ts b/src/addon/messages/providers/user-add-contact-handler.ts index 85a3f75ae..8c1e8241e 100644 --- a/src/addon/messages/providers/user-add-contact-handler.ts +++ b/src/addon/messages/providers/user-add-contact-handler.ts @@ -62,8 +62,8 @@ export class AddonMessagesAddContactUserHandler implements CoreUserProfileHandle * * @param {any} user User to check. * @param {number} courseId Course ID. - * @param {any} [navOptions] Course navigation options for current user. See $mmCourses#getUserNavigationOptions. - * @param {any} [admOptions] Course admin options for current user. See $mmCourses#getUserAdministrationOptions. + * @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. + * @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions. * @return {boolean|Promise} Promise resolved with true if enabled, resolved with false otherwise. */ isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { diff --git a/src/addon/messages/providers/user-block-contact-handler.ts b/src/addon/messages/providers/user-block-contact-handler.ts index 2af38b44f..1693dd538 100644 --- a/src/addon/messages/providers/user-block-contact-handler.ts +++ b/src/addon/messages/providers/user-block-contact-handler.ts @@ -62,8 +62,8 @@ export class AddonMessagesBlockContactUserHandler implements CoreUserProfileHand * * @param {any} user User to check. * @param {number} courseId Course ID. - * @param {any} [navOptions] Course navigation options for current user. See $mmCourses#getUserNavigationOptions. - * @param {any} [admOptions] Course admin options for current user. See $mmCourses#getUserAdministrationOptions. + * @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. + * @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions. * @return {boolean|Promise} Promise resolved with true if enabled, resolved with false otherwise. */ isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { diff --git a/src/addon/messages/providers/user-send-message-handler.ts b/src/addon/messages/providers/user-send-message-handler.ts index 1d1838c50..e42a2ca67 100644 --- a/src/addon/messages/providers/user-send-message-handler.ts +++ b/src/addon/messages/providers/user-send-message-handler.ts @@ -44,8 +44,8 @@ export class AddonMessagesSendMessageUserHandler implements CoreUserProfileHandl * * @param {any} user User to check. * @param {number} courseId Course ID. - * @param {any} [navOptions] Course navigation options for current user. See $mmCourses#getUserNavigationOptions. - * @param {any} [admOptions] Course admin options for current user. See $mmCourses#getUserAdministrationOptions. + * @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. + * @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions. * @return {boolean|Promise} Promise resolved with true if enabled, resolved with false otherwise. */ isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { diff --git a/src/addon/mod/book/providers/link-handler.ts b/src/addon/mod/book/providers/link-handler.ts index 1dc92ac85..1035ef3f9 100644 --- a/src/addon/mod/book/providers/link-handler.ts +++ b/src/addon/mod/book/providers/link-handler.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; -import { AddonModBookProvider } from './book'; /** * Handler to treat links to book. @@ -25,6 +24,6 @@ export class AddonModBookLinkHandler extends CoreContentLinksModuleIndexHandler name = 'AddonModBookLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, AddonModBookProvider.COMPONENT, 'book'); + super(courseHelper, 'AddonModBook', 'book'); } } diff --git a/src/addon/mod/folder/providers/folder.ts b/src/addon/mod/folder/providers/folder.ts index 0e7d80d33..63c5767bd 100644 --- a/src/addon/mod/folder/providers/folder.ts +++ b/src/addon/mod/folder/providers/folder.ts @@ -30,7 +30,7 @@ export class AddonModFolderProvider { constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private courseProvider: CoreCourseProvider, private utils: CoreUtilsProvider) { - this.logger = logger.getInstance('mmaModFolderProvider'); + this.logger = logger.getInstance('AddonModFolderProvider'); } /** diff --git a/src/addon/mod/folder/providers/link-handler.ts b/src/addon/mod/folder/providers/link-handler.ts index 6de6b010c..30db9d341 100644 --- a/src/addon/mod/folder/providers/link-handler.ts +++ b/src/addon/mod/folder/providers/link-handler.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; -import { AddonModFolderProvider } from './folder'; /** * Handler to treat links to resource. @@ -25,6 +24,6 @@ export class AddonModFolderLinkHandler extends CoreContentLinksModuleIndexHandle name = 'AddonModFolderLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, AddonModFolderProvider.COMPONENT, 'folder'); + super(courseHelper, 'AddonModFolder', 'folder'); } } diff --git a/src/addon/mod/label/providers/link-handler.ts b/src/addon/mod/label/providers/link-handler.ts index 72ed0d615..c1ef6fd67 100644 --- a/src/addon/mod/label/providers/link-handler.ts +++ b/src/addon/mod/label/providers/link-handler.ts @@ -24,6 +24,6 @@ export class AddonModLabelLinkHandler extends CoreContentLinksModuleIndexHandler name = 'AddonModLabelLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, 'mmaModLabel', 'label'); + super(courseHelper, 'AddonModLabel', 'label'); } } diff --git a/src/addon/mod/page/providers/link-handler.ts b/src/addon/mod/page/providers/link-handler.ts index 73f2ca507..339a6e202 100644 --- a/src/addon/mod/page/providers/link-handler.ts +++ b/src/addon/mod/page/providers/link-handler.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; -import { AddonModPageProvider } from './page'; /** * Handler to treat links to resource. @@ -25,6 +24,6 @@ export class AddonModPageLinkHandler extends CoreContentLinksModuleIndexHandler name = 'AddonModPageLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, AddonModPageProvider.COMPONENT, 'page'); + super(courseHelper, 'AddonModPage', 'page'); } } diff --git a/src/addon/mod/page/providers/page.ts b/src/addon/mod/page/providers/page.ts index aa9e68a18..11647e68b 100644 --- a/src/addon/mod/page/providers/page.ts +++ b/src/addon/mod/page/providers/page.ts @@ -31,7 +31,7 @@ export class AddonModPageProvider { constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private courseProvider: CoreCourseProvider, private utils: CoreUtilsProvider, private filepoolProvider: CoreFilepoolProvider) { - this.logger = logger.getInstance('mmaModPageProvider'); + this.logger = logger.getInstance('AddonModPageProvider'); } /** diff --git a/src/addon/mod/resource/providers/link-handler.ts b/src/addon/mod/resource/providers/link-handler.ts index 86ae7acc9..2a84bbf49 100644 --- a/src/addon/mod/resource/providers/link-handler.ts +++ b/src/addon/mod/resource/providers/link-handler.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; -import { AddonModResourceProvider } from './resource'; /** * Handler to treat links to resource. @@ -25,6 +24,6 @@ export class AddonModResourceLinkHandler extends CoreContentLinksModuleIndexHand name = 'AddonModResourceLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, AddonModResourceProvider.COMPONENT, 'resource'); + super(courseHelper, 'AddonModResource', 'resource'); } } diff --git a/src/addon/mod/survey/providers/link-handler.ts b/src/addon/mod/survey/providers/link-handler.ts index 5db79d39b..0189bcc4a 100644 --- a/src/addon/mod/survey/providers/link-handler.ts +++ b/src/addon/mod/survey/providers/link-handler.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; -import { AddonModSurveyProvider } from './survey'; /** * Handler to treat links to survey. @@ -25,6 +24,6 @@ export class AddonModSurveyLinkHandler extends CoreContentLinksModuleIndexHandle name = 'AddonModSurveyLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, AddonModSurveyProvider.COMPONENT, 'survey'); + super(courseHelper, 'AddonModSurvey', 'survey'); } } diff --git a/src/addon/mod/url/providers/link-handler.ts b/src/addon/mod/url/providers/link-handler.ts index c9ad1c24b..d880a0b9a 100644 --- a/src/addon/mod/url/providers/link-handler.ts +++ b/src/addon/mod/url/providers/link-handler.ts @@ -15,7 +15,6 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler'; import { CoreCourseHelperProvider } from '@core/course/providers/helper'; -import { AddonModUrlProvider } from './url'; /** * Handler to treat links to url. @@ -25,6 +24,6 @@ export class AddonModUrlLinkHandler extends CoreContentLinksModuleIndexHandler { name = 'AddonModUrlLinkHandler'; constructor(courseHelper: CoreCourseHelperProvider) { - super(courseHelper, AddonModUrlProvider.COMPONENT, 'url'); + super(courseHelper, 'AddonModUrl', 'url'); } } diff --git a/src/addon/notes/providers/user-handler.ts b/src/addon/notes/providers/user-handler.ts index ad48c0f06..ffa1c367c 100644 --- a/src/addon/notes/providers/user-handler.ts +++ b/src/addon/notes/providers/user-handler.ts @@ -25,7 +25,7 @@ import { AddonNotesProvider } from './notes'; */ @Injectable() export class AddonNotesUserHandler implements CoreUserProfileHandler { - name = 'AddonNotes'; + name = 'AddonNotes:addNote'; priority = 200; type = CoreUserDelegate.TYPE_COMMUNICATION; addNoteEnabledCache = {}; @@ -65,8 +65,8 @@ export class AddonNotesUserHandler implements CoreUserProfileHandler { * * @param {any} user User to check. * @param {number} courseId Course ID. - * @param {any} [navOptions] Course navigation options for current user. See $mmCourses#getUserNavigationOptions. - * @param {any} [admOptions] Course admin options for current user. See $mmCourses#getUserAdministrationOptions. + * @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. + * @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions. * @return {boolean|Promise} Promise resolved with true if enabled, resolved with false otherwise. */ isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { diff --git a/src/classes/site.ts b/src/classes/site.ts index 3846ae746..d01a31ac2 100644 --- a/src/classes/site.ts +++ b/src/classes/site.ts @@ -146,18 +146,18 @@ export interface LocalMobileResponse { */ export class CoreSite { // List of injected services. This class isn't injectable, so it cannot use DI. - protected appProvider; - protected dbProvider; - protected domUtils; - protected eventsProvider; - protected fileProvider; - protected http; - protected textUtils; - protected timeUtils; - protected translate; - protected utils; - protected urlUtils; - protected wsProvider; + protected appProvider: CoreAppProvider; + protected dbProvider: CoreDbProvider; + protected domUtils: CoreDomUtilsProvider; + protected eventsProvider: CoreEventsProvider; + protected fileProvider: CoreFileProvider; + protected http: HttpClient; + protected textUtils: CoreTextUtilsProvider; + protected timeUtils: CoreTimeUtilsProvider; + protected translate: TranslateService; + protected utils: CoreUtilsProvider; + protected urlUtils: CoreUrlUtilsProvider; + protected wsProvider: CoreWSProvider; // Variables for the database. protected WS_CACHE_TABLE = 'wscache'; @@ -184,18 +184,20 @@ export class CoreSite { ] }; - // Rest of variables. - protected logger; - protected db: SQLiteDB; - protected cleanUnicode = false; - protected lastAutoLogin = 0; - protected moodleReleases = { + // Versions of Moodle releases. + protected MOODLE_RELEASES = { 3.1: 2016052300, 3.2: 2016120500, 3.3: 2017051503, 3.4: 2017111300 }; + // Rest of variables. + protected logger; + protected db: SQLiteDB; + protected cleanUnicode = false; + protected lastAutoLogin = 0; + /** * Create a site. * @@ -366,6 +368,7 @@ export class CoreSite { * @param {any} Config. */ setConfig(config: any): void { + config.tool_mobile_disabledfeatures = this.textUtils.treatDisabledFeatures(config.tool_mobile_disabledfeatures); this.config = config; } @@ -935,7 +938,7 @@ export class CoreSite { const siteFolder = this.fileProvider.getSiteFolder(this.id); return this.fileProvider.removeDir(siteFolder).catch(() => { - // Ignore any errors, $mmFS.removeDir fails if folder doesn't exists. + // Ignore any errors, CoreFileProvider.removeDir fails if folder doesn't exists. }); } else { return Promise.resolve(); @@ -1133,9 +1136,9 @@ export class CoreSite { * @param {string} url The URL to open. * @param {any} [options] Override default options passed to InAppBrowser. * @param {string} [alertMessage] If defined, an alert will be shown before opening the inappbrowser. - * @return {Promise} Promise resolved when done. + * @return {Promise} Promise resolved when done. */ - openInAppWithAutoLogin(url: string, options?: any, alertMessage?: string): Promise { + openInAppWithAutoLogin(url: string, options?: any, alertMessage?: string): Promise { return this.openWithAutoLogin(true, url, options, alertMessage); } @@ -1145,9 +1148,9 @@ export class CoreSite { * @param {string} url The URL to open. * @param {object} [options] Override default options passed to inappbrowser. * @param {string} [alertMessage] If defined, an alert will be shown before opening the inappbrowser. - * @return {Promise} Promise resolved when done. + * @return {Promise} Promise resolved when done. */ - openInAppWithAutoLoginIfSameSite(url: string, options?: any, alertMessage?: string): Promise { + openInAppWithAutoLoginIfSameSite(url: string, options?: any, alertMessage?: string): Promise { return this.openWithAutoLoginIfSameSite(true, url, options, alertMessage); } @@ -1158,12 +1161,12 @@ export class CoreSite { * @param {string} url The URL to open. * @param {object} [options] Override default options passed to $cordovaInAppBrowser#open. * @param {string} [alertMessage] If defined, an alert will be shown before opening the browser/inappbrowser. - * @return {Promise} Promise resolved when done. Resolve param is returned only if inApp=true. + * @return {Promise} Promise resolved when done. Resolve param is returned only if inApp=true. */ - openWithAutoLogin(inApp: boolean, url: string, options?: any, alertMessage?: string): Promise { + openWithAutoLogin(inApp: boolean, url: string, options?: any, alertMessage?: string): Promise { // Convenience function to open the URL. const open = (url): Promise => { - return new Promise((resolve, reject): void => { + return new Promise((resolve, reject): void => { if (modal) { modal.dismiss(); } @@ -1223,9 +1226,10 @@ export class CoreSite { * @param {string} url The URL to open. * @param {object} [options] Override default options passed to inappbrowser. * @param {string} [alertMessage] If defined, an alert will be shown before opening the browser/inappbrowser. - * @return {Promise} Promise resolved when done. Resolve param is returned only if inApp=true. + * @return {Promise} Promise resolved when done. Resolve param is returned only if inApp=true. */ - openWithAutoLoginIfSameSite(inApp: boolean, url: string, options?: any, alertMessage?: string): Promise { + openWithAutoLoginIfSameSite(inApp: boolean, url: string, options?: any, alertMessage?: string) + : Promise { if (this.containsUrl(url)) { return this.openWithAutoLogin(inApp, url, options, alertMessage); } else { @@ -1396,12 +1400,12 @@ export class CoreSite { return 0; } - if (typeof this.moodleReleases[data.major] == 'undefined') { + if (typeof this.MOODLE_RELEASES[data.major] == 'undefined') { // Major version not found. Use the last one. - data.major = Object.keys(this.moodleReleases).slice(-1); + data.major = Object.keys(this.MOODLE_RELEASES).slice(-1); } - return this.moodleReleases[data.major] + data.minor; + return this.MOODLE_RELEASES[data.major] + data.minor; } /** @@ -1431,7 +1435,7 @@ export class CoreSite { */ protected getNextMajorVersionNumber(version: string): number { const data = this.getMajorAndMinor(version), - releases = Object.keys(this.moodleReleases); + releases = Object.keys(this.MOODLE_RELEASES); let position; if (!data) { @@ -1443,9 +1447,9 @@ export class CoreSite { if (position == -1 || position == releases.length - 1) { // Major version not found or it's the last one. Use the last one. - return this.moodleReleases[releases[position]]; + return this.MOODLE_RELEASES[releases[position]]; } - return this.moodleReleases[releases[position + 1]]; + return this.MOODLE_RELEASES[releases[position + 1]]; } } diff --git a/src/core/contentlinks/classes/module-grade-handler.ts b/src/core/contentlinks/classes/module-grade-handler.ts index 68c26f9b6..02ade7789 100644 --- a/src/core/contentlinks/classes/module-grade-handler.ts +++ b/src/core/contentlinks/classes/module-grade-handler.ts @@ -45,7 +45,7 @@ export class CoreContentLinksModuleGradeHandler extends CoreContentLinksHandlerB // Match the grade.php URL with an id param. this.pattern = new RegExp('\/mod\/' + modName + '\/grade\.php.*([\&\?]id=\\d+)'); - this.featureName = '$mmCourseDelegate_' + addon; + this.featureName = 'CoreCourseModuleDelegate_' + addon; } /** diff --git a/src/core/contentlinks/classes/module-index-handler.ts b/src/core/contentlinks/classes/module-index-handler.ts index 28413ed26..2a10bee94 100644 --- a/src/core/contentlinks/classes/module-index-handler.ts +++ b/src/core/contentlinks/classes/module-index-handler.ts @@ -33,7 +33,7 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB // Match the view.php URL with an id param. this.pattern = new RegExp('\/mod\/' + modName + '\/view\.php.*([\&\?]id=\\d+)'); - this.featureName = '$mmCourseDelegate_' + addon; + this.featureName = 'CoreCourseModuleDelegate_' + addon; } /** diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index 9457b4ff3..8bc95c52b 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -758,11 +758,8 @@ export class CoreCourseHelperProvider { /** * Get a course status icon from status. * - * @module mm.core.course - * @ngdoc method - * @name $mmCourseHelper#getCourseStatusIconFromStatus - * @param {String} status Course status. - * @return {String} Icon name. + * @param {string} status Course status. + * @return {string} Icon name. */ getCourseStatusIconFromStatus(status: string): string { if (status == CoreConstants.DOWNLOADED) { diff --git a/src/core/course/providers/module-delegate.ts b/src/core/course/providers/module-delegate.ts index 27cc1eab8..a162e1f0a 100644 --- a/src/core/course/providers/module-delegate.ts +++ b/src/core/course/providers/module-delegate.ts @@ -168,7 +168,7 @@ export interface CoreCourseModuleHandlerButton { export class CoreCourseModuleDelegate extends CoreDelegate { protected handlers: { [s: string]: CoreCourseModuleHandler } = {}; // All registered handlers. protected enabledHandlers: { [s: string]: CoreCourseModuleHandler } = {}; // Handlers enabled for the current site. - protected featurePrefix = '$mmCourseDelegate_'; + protected featurePrefix = 'CoreCourseModuleDelegate_'; constructor(loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, eventsProvider: CoreEventsProvider, protected courseProvider: CoreCourseProvider) { diff --git a/src/core/course/providers/options-delegate.ts b/src/core/course/providers/options-delegate.ts index 569476d70..440ab2cc4 100644 --- a/src/core/course/providers/options-delegate.ts +++ b/src/core/course/providers/options-delegate.ts @@ -139,7 +139,7 @@ export class CoreCourseOptionsDelegate extends CoreDelegate { } } = {}; - protected featurePrefix = '$mmCoursesDelegate_'; + protected featurePrefix = 'CoreCourseOptionsDelegate_'; constructor(loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider, protected eventsProvider: CoreEventsProvider, private coursesProvider: CoreCoursesProvider) { diff --git a/src/core/courses/providers/courses-index-link-handler.ts b/src/core/courses/providers/courses-index-link-handler.ts index 0183689df..834629eac 100644 --- a/src/core/courses/providers/courses-index-link-handler.ts +++ b/src/core/courses/providers/courses-index-link-handler.ts @@ -24,7 +24,7 @@ import { CoreCoursesProvider } from './courses'; @Injectable() export class CoreCoursesIndexLinkHandler extends CoreContentLinksHandlerBase { name = 'CoreCoursesIndexLinkHandler'; - featureName = '$mmSideMenuDelegate_mmCourses'; + featureName = 'CoreMainMenuDelegate_CoreCourses'; pattern = /\/course\/?(index\.php.*)?$/; constructor(private coursesProvider: CoreCoursesProvider, private loginHelper: CoreLoginHelperProvider) { diff --git a/src/core/courses/providers/courses.ts b/src/core/courses/providers/courses.ts index 3118858dd..84a8ba485 100644 --- a/src/core/courses/providers/courses.ts +++ b/src/core/courses/providers/courses.ts @@ -141,7 +141,7 @@ export class CoreCoursesProvider { isMyCoursesDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmSideMenuDelegate_mmCourses'); + return site.isFeatureDisabled('CoreMainMenuDelegate_CoreCourses'); } /** @@ -165,7 +165,7 @@ export class CoreCoursesProvider { isSearchCoursesDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmCoursesDelegate_search'); + return site.isFeatureDisabled('CoreCourseOptionsDelegate_search'); } /** diff --git a/src/core/courses/providers/my-overview-link-handler.ts b/src/core/courses/providers/my-overview-link-handler.ts index e35151615..6bd87143a 100644 --- a/src/core/courses/providers/my-overview-link-handler.ts +++ b/src/core/courses/providers/my-overview-link-handler.ts @@ -23,7 +23,7 @@ import { CoreLoginHelperProvider } from '@core/login/providers/helper'; @Injectable() export class CoreCoursesMyOverviewLinkHandler extends CoreContentLinksHandlerBase { name = 'CoreCoursesMyOverviewLinkHandler'; - featureName = '$mmSideMenuDelegate_mmCourses'; + featureName = 'CoreMainMenuDelegate_CoreCourses'; pattern = /\/my\/?$/; constructor(private loginHelper: CoreLoginHelperProvider) { diff --git a/src/core/courses/providers/my-overview.ts b/src/core/courses/providers/my-overview.ts index 1e744da3c..d64d0dbca 100644 --- a/src/core/courses/providers/my-overview.ts +++ b/src/core/courses/providers/my-overview.ts @@ -231,7 +231,7 @@ export class CoreCoursesMyOverviewProvider { isDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmSideMenuDelegate_mmaMyOverview'); + return site.isFeatureDisabled('CoreMainMenuDelegate_CoreCourses'); } /** diff --git a/src/core/grades/providers/user-handler.ts b/src/core/grades/providers/user-handler.ts index b7f5f42bf..1b8e61de9 100644 --- a/src/core/grades/providers/user-handler.ts +++ b/src/core/grades/providers/user-handler.ts @@ -23,7 +23,7 @@ import { CoreGradesProvider } from './grades'; */ @Injectable() export class CoreGradesUserHandler implements CoreUserProfileHandler { - name = 'mmGrades'; + name = 'CoreGrades:viewGrades'; priority = 400; type = CoreUserDelegate.TYPE_NEW_PAGE; viewGradesEnabledCache = {}; @@ -71,8 +71,8 @@ export class CoreGradesUserHandler implements CoreUserProfileHandler { * * @param {any} user User to check. * @param {number} courseId Course ID. - * @param {any} [navOptions] Course navigation options for current user. See $mmCourses#getUserNavigationOptions. - * @param {any} [admOptions] Course admin options for current user. See $mmCourses#getUserAdministrationOptions. + * @param {any} [navOptions] Course navigation options for current user. See CoreCoursesProvider.getUserNavigationOptions. + * @param {any} [admOptions] Course admin options for current user. See CoreCoursesProvider.getUserAdministrationOptions. * @return {boolean|Promise} Promise resolved with true if enabled, resolved with false otherwise. */ isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { diff --git a/src/core/login/providers/helper.ts b/src/core/login/providers/helper.ts index 482a7b356..6b45c3571 100644 --- a/src/core/login/providers/helper.ts +++ b/src/core/login/providers/helper.ts @@ -489,12 +489,14 @@ export class CoreLoginHelperProvider { * @return {boolean} Whether email signup is disabled. */ isEmailSignupDisabled(config: any): boolean { - const disabledFeatures = config && config.tool_mobile_disabledfeatures; + let disabledFeatures = config && config.tool_mobile_disabledfeatures; if (!disabledFeatures) { return false; } - const regEx = new RegExp('(,|^)\\$mmLoginEmailSignup(,|$)', 'g'); + disabledFeatures = this.textUtils.treatDisabledFeatures(disabledFeatures); + + const regEx = new RegExp('(,|^)CoreLoginEmailSignup(,|$)', 'g'); return !!disabledFeatures.match(regEx); } @@ -744,8 +746,8 @@ export class CoreLoginHelperProvider { loginUrl += '&passport=' + passport; loginUrl += '&urlscheme=' + CoreConfigConstants.customurlscheme; - // Store the siteurl and passport in $mmConfig for persistence. - // We are "configuring" the app to wait for an SSO. $mmConfig shouldn't be used as a temporary storage. + // Store the siteurl and passport in CoreConfigProvider for persistence. + // We are "configuring" the app to wait for an SSO. CoreConfigProvider shouldn't be used as a temporary storage. this.configProvider.set(CoreConstants.LOGIN_LAUNCH_DATA, JSON.stringify({ siteUrl: siteUrl, passport: passport, diff --git a/src/core/mainmenu/pages/more/more.ts b/src/core/mainmenu/pages/more/more.ts index 9be9b6238..b3a4f6608 100644 --- a/src/core/mainmenu/pages/more/more.ts +++ b/src/core/mainmenu/pages/more/more.ts @@ -80,8 +80,8 @@ export class CoreMainMenuMorePage implements OnDestroy { this.siteInfo = currentSite.getInfo(); this.logoutLabel = 'core.mainmenu.' + (config && config.tool_mobile_forcelogout == '1' ? 'logout' : 'changesite'); - this.showWeb = !currentSite.isFeatureDisabled('$mmSideMenuDelegate_website'); - this.showHelp = !currentSite.isFeatureDisabled('$mmSideMenuDelegate_help'); + this.showWeb = !currentSite.isFeatureDisabled('CoreMainMenuDelegate_website'); + this.showHelp = !currentSite.isFeatureDisabled('CoreMainMenuDelegate_help'); currentSite.getDocsUrl().then((docsUrl) => { this.docsUrl = docsUrl; diff --git a/src/core/mainmenu/providers/delegate.ts b/src/core/mainmenu/providers/delegate.ts index 23ac7e847..1ffa81b5f 100644 --- a/src/core/mainmenu/providers/delegate.ts +++ b/src/core/mainmenu/providers/delegate.ts @@ -111,7 +111,7 @@ export class CoreMainMenuDelegate extends CoreDelegate { protected enabledHandlers: { [s: string]: CoreMainMenuHandler } = {}; protected loaded = false; protected siteHandlers: Subject = new BehaviorSubject([]); - protected featurePrefix = '$mmSideMenuDelegate_'; + protected featurePrefix = 'CoreMainMenuDelegate_'; constructor(protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, protected eventsProvider: CoreEventsProvider) { diff --git a/src/core/sitehome/providers/index-link-handler.ts b/src/core/sitehome/providers/index-link-handler.ts index d8d5c5c64..eb2cb5906 100644 --- a/src/core/sitehome/providers/index-link-handler.ts +++ b/src/core/sitehome/providers/index-link-handler.ts @@ -25,7 +25,7 @@ import { CoreSiteHomeProvider } from './sitehome'; @Injectable() export class CoreSiteHomeIndexLinkHandler extends CoreContentLinksHandlerBase { name = 'CoreSiteHomeIndexLinkHandler'; - featureName = '$mmSideMenuDelegate_mmaFrontpage'; + featureName = 'CoreMainMenuDelegate_CoreSiteHome'; pattern = /\/course\/view\.php.*([\?\&]id=\d+)/; constructor(private sitesProvider: CoreSitesProvider, private siteHomeProvider: CoreSiteHomeProvider, diff --git a/src/core/sitehome/providers/sitehome.ts b/src/core/sitehome/providers/sitehome.ts index de8957226..41ee3893d 100644 --- a/src/core/sitehome/providers/sitehome.ts +++ b/src/core/sitehome/providers/sitehome.ts @@ -100,6 +100,6 @@ export class CoreSiteHomeProvider { isDisabledInSite(site: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmSideMenuDelegate_mmaFrontpage'); + return site.isFeatureDisabled('CoreMainMenuDelegate_CoreSiteHome'); } } diff --git a/src/core/user/providers/participants-link-handler.ts b/src/core/user/providers/participants-link-handler.ts index 4d4f93918..910b57eb6 100644 --- a/src/core/user/providers/participants-link-handler.ts +++ b/src/core/user/providers/participants-link-handler.ts @@ -24,7 +24,7 @@ import { CoreUserProvider } from './user'; @Injectable() export class CoreUserParticipantsLinkHandler extends CoreContentLinksHandlerBase { name = 'CoreUserParticipants'; - featureName = '$mmCoursesDelegate_mmaParticipants'; + featureName = 'CoreCourseOptionsDelegate_CoreUserParticipants'; pattern = /\/user\/index\.php/; constructor(private userProvider: CoreUserProvider, private loginHelper: CoreLoginHelperProvider) { diff --git a/src/core/user/providers/user-delegate.ts b/src/core/user/providers/user-delegate.ts index 8716bd8b6..cb8f9de98 100644 --- a/src/core/user/providers/user-delegate.ts +++ b/src/core/user/providers/user-delegate.ts @@ -167,7 +167,7 @@ export class CoreUserDelegate extends CoreDelegate { protected observableHandlers: Subject = new BehaviorSubject([]); protected userHandlers: CoreUserProfileHandlerToDisplay[] = []; - protected featurePrefix = '$mmUserDelegate_'; + protected featurePrefix = 'CoreUserDelegate_'; protected loaded = false; constructor(protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider, diff --git a/src/core/user/providers/user-handler.ts b/src/core/user/providers/user-handler.ts index 7414dd287..8437b3e8b 100644 --- a/src/core/user/providers/user-handler.ts +++ b/src/core/user/providers/user-handler.ts @@ -21,7 +21,7 @@ import { CoreSitesProvider } from '@providers/sites'; */ @Injectable() export class CoreUserProfileMailHandler implements CoreUserProfileHandler { - name = 'mmUser'; + name = 'CoreUserProfileMail'; priority = 700; type = CoreUserDelegate.TYPE_COMMUNICATION; diff --git a/src/core/user/providers/user.ts b/src/core/user/providers/user.ts index 7dfc1ae0e..f9f3c95d0 100644 --- a/src/core/user/providers/user.ts +++ b/src/core/user/providers/user.ts @@ -306,7 +306,7 @@ export class CoreUserProvider { isParticipantsDisabledInSite(site?: any): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmCoursesDelegate_mmaParticipants'); + return site.isFeatureDisabled('CoreCourseOptionsDelegate_CoreUserParticipants'); } /** @@ -334,7 +334,7 @@ export class CoreUserProvider { isUpdatePictureDisabledInSite(site?: CoreSite): boolean { site = site || this.sitesProvider.getCurrentSite(); - return site.isFeatureDisabled('$mmUserDelegate_picture'); + return site.isFeatureDisabled('CoreUserDelegate_picture'); } /** diff --git a/src/providers/app.ts b/src/providers/app.ts index 1cac19e4b..75c9c0991 100644 --- a/src/providers/app.ts +++ b/src/providers/app.ts @@ -323,10 +323,10 @@ export class CoreAppProvider { if (localStorage && localStorage.getItem) { try { const data: CoreRedirectData = { - siteId: localStorage.getItem('mmCoreRedirectSiteId'), - page: localStorage.getItem('mmCoreRedirectState'), - params: localStorage.getItem('mmCoreRedirectParams'), - timemodified: parseInt(localStorage.getItem('mmCoreRedirectTime'), 10) + siteId: localStorage.getItem('CoreRedirectSiteId'), + page: localStorage.getItem('CoreRedirectState'), + params: localStorage.getItem('CoreRedirectParams'), + timemodified: parseInt(localStorage.getItem('CoreRedirectTime'), 10) }; if (data.params) { @@ -352,10 +352,10 @@ export class CoreAppProvider { storeRedirect(siteId: string, page: string, params: any): void { if (localStorage && localStorage.setItem) { try { - localStorage.setItem('mmCoreRedirectSiteId', siteId); - localStorage.setItem('mmCoreRedirectState', page); - localStorage.setItem('mmCoreRedirectParams', JSON.stringify(params)); - localStorage.setItem('mmCoreRedirectTime', String(Date.now())); + localStorage.setItem('CoreRedirectSiteId', siteId); + localStorage.setItem('CoreRedirectState', page); + localStorage.setItem('CoreRedirectParams', JSON.stringify(params)); + localStorage.setItem('CoreRedirectTime', String(Date.now())); } catch (ex) { // Ignore errors. } diff --git a/src/providers/filepool.ts b/src/providers/filepool.ts index 115964a7c..8663b050f 100644 --- a/src/providers/filepool.ts +++ b/src/providers/filepool.ts @@ -242,11 +242,11 @@ export class CoreFilepoolProvider { protected FOLDER = 'filepool'; protected WIFI_DOWNLOAD_THRESHOLD = 20971520; // 20MB. protected DOWNLOAD_THRESHOLD = 2097152; // 2MB. - protected QUEUE_RUNNING = 'mmFilepool:QUEUE_RUNNING'; - protected QUEUE_PAUSED = 'mmFilepool:QUEUE_PAUSED'; - protected ERR_QUEUE_IS_EMPTY = 'mmFilepoolError:ERR_QUEUE_IS_EMPTY'; - protected ERR_FS_OR_NETWORK_UNAVAILABLE = 'mmFilepoolError:ERR_FS_OR_NETWORK_UNAVAILABLE'; - protected ERR_QUEUE_ON_PAUSE = 'mmFilepoolError:ERR_QUEUE_ON_PAUSE'; + protected QUEUE_RUNNING = 'CoreFilepool:QUEUE_RUNNING'; + protected QUEUE_PAUSED = 'CoreFilepool:QUEUE_PAUSED'; + protected ERR_QUEUE_IS_EMPTY = 'CoreFilepoolError:ERR_QUEUE_IS_EMPTY'; + protected ERR_FS_OR_NETWORK_UNAVAILABLE = 'CoreFilepoolError:ERR_FS_OR_NETWORK_UNAVAILABLE'; + protected ERR_QUEUE_ON_PAUSE = 'CoreFilepoolError:ERR_QUEUE_ON_PAUSE'; // Variables for database. protected QUEUE_TABLE = 'filepool_files_queue'; // Queue of files to download. @@ -1369,7 +1369,7 @@ export class CoreFilepoolProvider { * @return {string} Event name. */ protected getFileEventName(siteId: string, fileId: string): string { - return 'mmFilepoolFile:' + siteId + ':' + fileId; + return 'CoreFilepoolFile:' + siteId + ':' + fileId; } /** diff --git a/src/providers/init.ts b/src/providers/init.ts index ff27eb733..e06ce450d 100644 --- a/src/providers/init.ts +++ b/src/providers/init.ts @@ -107,8 +107,6 @@ export class CoreInitDelegate { /** * Instantly returns if the app is ready. * - * To be notified when the app is ready, refer to {@link $mmApp#ready}. - * * @return {boolean} Whether it's ready. */ isReady(): boolean { diff --git a/src/providers/utils/text.ts b/src/providers/utils/text.ts index bb7d26c17..3020d4ce6 100644 --- a/src/providers/utils/text.ts +++ b/src/providers/utils/text.ts @@ -22,6 +22,52 @@ import { CoreLangProvider } from '../lang'; */ @Injectable() export class CoreTextUtilsProvider { + + // List of regular expressions to convert the old nomenclature to new nomenclature for disabled features. + protected DISABLED_FEATURES_COMPAT_REGEXPS = [ + {old: /\$mmLoginEmailSignup/g, new: 'CoreLoginEmailSignup'}, + {old: /\$mmSideMenuDelegate/g, new: 'CoreMainMenuDelegate'}, + {old: /\$mmCoursesDelegate/g, new: 'CoreCourseOptionsDelegate'}, + {old: /\$mmUserDelegate/g, new: 'CoreUserDelegate'}, + {old: /\$mmCourseDelegate/g, new: 'CoreCourseModuleDelegate'}, + {old: /_mmCourses/g, new: '_CoreCourses'}, + {old: /_mmaFrontpage/g, new: '_CoreSiteHome'}, + {old: /_mmaGrades/g, new: '_CoreGrades'}, + {old: /_mmaCompetency/g, new: '_AddonCompetency'}, + {old: /_mmaNotifications/g, new: '_AddonNotifications'}, + {old: /_mmaMessages/g, new: '_AddonMessages'}, + {old: /_mmaCalendar/g, new: '_AddonCalendar'}, + {old: /_mmaFiles/g, new: '_AddonFiles'}, + {old: /_mmaParticipants/g, new: '_CoreUserParticipants'}, + {old: /_mmaCourseCompletion/g, new: '_AddonCourseCompletion'}, + {old: /_mmaNotes/g, new: '_AddonNotes'}, + {old: /_mmaBadges/g, new: '_AddonBadges'}, + {old: /files_privatefiles/g, new: 'AddonFilesPrivateFiles'}, + {old: /files_sitefiles/g, new: 'AddonFilesSiteFiles'}, + {old: /files_upload/g, new: 'AddonFilesUpload'}, + {old: /_mmaModAssign/g, new: '_AddonModAssign'}, + {old: /_mmaModBook/g, new: '_AddonModBook'}, + {old: /_mmaModChat/g, new: '_AddonModChat'}, + {old: /_mmaModChoice/g, new: '_AddonModChoice'}, + {old: /_mmaModData/g, new: '_AddonModData'}, + {old: /_mmaModFeedback/g, new: '_AddonModFeedback'}, + {old: /_mmaModFolder/g, new: '_AddonModFolder'}, + {old: /_mmaModForum/g, new: '_AddonModForum'}, + {old: /_mmaModGlossary/g, new: '_AddonModGlossary'}, + {old: /_mmaModImscp/g, new: '_AddonModImscp'}, + {old: /_mmaModLabel/g, new: '_AddonModLabel'}, + {old: /_mmaModLesson/g, new: '_AddonModLesson'}, + {old: /_mmaModLti/g, new: '_AddonModLti'}, + {old: /_mmaModPage/g, new: '_AddonModPage'}, + {old: /_mmaModQuiz/g, new: '_AddonModQuiz'}, + {old: /_mmaModResource/g, new: '_AddonModResource'}, + {old: /_mmaModScorm/g, new: '_AddonModScorm'}, + {old: /_mmaModSurvey/g, new: '_AddonModSurvey'}, + {old: /_mmaModUrl/g, new: '_AddonModUrl'}, + {old: /_mmaModWiki/g, new: '_AddonModWiki'}, + {old: /_mmaModWorkshop/g, new: '_AddonModWorkshop'}, + ]; + protected element = document.createElement('div'); // Fake element to use in some functions, to prevent creating it each time. constructor(private translate: TranslateService, private langProvider: CoreLangProvider, private modalCtrl: ModalController) { } @@ -534,6 +580,26 @@ export class CoreTextUtilsProvider { return stripped; } + /** + * Treat the list of disabled features, replacing old nomenclature with the new one. + * + * @param {string} features List of disabled features. + * @return {string} Treated list. + */ + treatDisabledFeatures(features: string): string { + if (!features) { + return ''; + } + + for (let i = 0; i < this.DISABLED_FEATURES_COMPAT_REGEXPS.length; i++) { + const entry = this.DISABLED_FEATURES_COMPAT_REGEXPS[i]; + + features = features.replace(entry.old, entry.new); + } + + return features; + } + /** * Treat the multilang tags from a HTML code, leaving only the current language. *