MOBILE-2391 core: Use new nomenclature in disabled features

main
Dani Palou 2018-03-23 11:57:13 +01:00
parent c46aacce4c
commit c1cf6e5b21
43 changed files with 177 additions and 116 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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');
}
/**

View File

@ -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<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {

View File

@ -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');
}
/**

View File

@ -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;

View File

@ -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<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {

View File

@ -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<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {

View File

@ -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<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {

View File

@ -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');
}
}

View File

@ -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');
}
/**

View File

@ -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');
}
}

View File

@ -24,6 +24,6 @@ export class AddonModLabelLinkHandler extends CoreContentLinksModuleIndexHandler
name = 'AddonModLabelLinkHandler';
constructor(courseHelper: CoreCourseHelperProvider) {
super(courseHelper, 'mmaModLabel', 'label');
super(courseHelper, 'AddonModLabel', 'label');
}
}

View File

@ -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');
}
}

View File

@ -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');
}
/**

View File

@ -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');
}
}

View File

@ -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');
}
}

View File

@ -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');
}
}

View File

@ -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<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {

View File

@ -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<InAppBrowserObject>} Promise resolved when done.
* @return {Promise<InAppBrowserObject|void>} Promise resolved when done.
*/
openInAppWithAutoLogin(url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject> {
openInAppWithAutoLogin(url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject | void> {
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<InAppBrowserObject>} Promise resolved when done.
* @return {Promise<InAppBrowserObject|void>} Promise resolved when done.
*/
openInAppWithAutoLoginIfSameSite(url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject> {
openInAppWithAutoLoginIfSameSite(url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject | void> {
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<InAppBrowserObject>} Promise resolved when done. Resolve param is returned only if inApp=true.
* @return {Promise<InAppBrowserObject|void>} Promise resolved when done. Resolve param is returned only if inApp=true.
*/
openWithAutoLogin(inApp: boolean, url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject> {
openWithAutoLogin(inApp: boolean, url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject | void> {
// Convenience function to open the URL.
const open = (url): Promise<any> => {
return new Promise<InAppBrowserObject>((resolve, reject): void => {
return new Promise<InAppBrowserObject | void>((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<InAppBrowserObject>} Promise resolved when done. Resolve param is returned only if inApp=true.
* @return {Promise<InAppBrowserObject|void>} Promise resolved when done. Resolve param is returned only if inApp=true.
*/
openWithAutoLoginIfSameSite(inApp: boolean, url: string, options?: any, alertMessage?: string): Promise<InAppBrowserObject> {
openWithAutoLoginIfSameSite(inApp: boolean, url: string, options?: any, alertMessage?: string)
: Promise<InAppBrowserObject | void> {
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]];
}
}

View File

@ -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;
}
/**

View File

@ -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;
}
/**

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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');
}
/**

View File

@ -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) {

View File

@ -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');
}
/**

View File

@ -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<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise<boolean> {

View File

@ -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,

View File

@ -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;

View File

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

View File

@ -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,

View File

@ -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');
}
}

View File

@ -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) {

View File

@ -167,7 +167,7 @@ export class CoreUserDelegate extends CoreDelegate {
protected observableHandlers: Subject<CoreUserProfileHandlerToDisplay[]> =
new BehaviorSubject<CoreUserProfileHandlerToDisplay[]>([]);
protected userHandlers: CoreUserProfileHandlerToDisplay[] = [];
protected featurePrefix = '$mmUserDelegate_';
protected featurePrefix = 'CoreUserDelegate_';
protected loaded = false;
constructor(protected loggerProvider: CoreLoggerProvider, protected sitesProvider: CoreSitesProvider,

View File

@ -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;

View File

@ -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');
}
/**

View File

@ -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.
}

View File

@ -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;
}
/**

View File

@ -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 {

View File

@ -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.
*