MOBILE-4632 siteplugins: Minor changes on declarations
This commit is contained in:
		
							parent
							
								
									eb9935a1d7
								
							
						
					
					
						commit
						e8a1ff89fa
					
				@ -13,3 +13,7 @@
 | 
				
			|||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT = 'siteplugins_update_course_content';
 | 
					export const CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT = 'siteplugins_update_course_content';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const CORE_SITE_PLUGINS_COMPONENT = 'CoreSitePlugins';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const CORE_SITE_PLUGINS_PATH = 'siteplugins';
 | 
				
			||||||
 | 
				
			|||||||
@ -62,7 +62,6 @@ import {
 | 
				
			|||||||
    CoreSitePluginsContent,
 | 
					    CoreSitePluginsContent,
 | 
				
			||||||
    CoreSitePluginsPlugin,
 | 
					    CoreSitePluginsPlugin,
 | 
				
			||||||
    CoreSitePluginsHandlerData,
 | 
					    CoreSitePluginsHandlerData,
 | 
				
			||||||
    CoreSitePluginsProvider,
 | 
					 | 
				
			||||||
    CoreSitePluginsCourseOptionHandlerData,
 | 
					    CoreSitePluginsCourseOptionHandlerData,
 | 
				
			||||||
    CoreSitePluginsMainMenuHandlerData,
 | 
					    CoreSitePluginsMainMenuHandlerData,
 | 
				
			||||||
    CoreSitePluginsCourseModuleHandlerData,
 | 
					    CoreSitePluginsCourseModuleHandlerData,
 | 
				
			||||||
@ -89,8 +88,7 @@ import { CoreUrlUtils } from '@services/utils/url';
 | 
				
			|||||||
import { CorePath } from '@singletons/path';
 | 
					import { CorePath } from '@singletons/path';
 | 
				
			||||||
import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate';
 | 
					import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate';
 | 
				
			||||||
import { CoreSitePluginsEnrolHandler } from '../classes/handlers/enrol-handler';
 | 
					import { CoreSitePluginsEnrolHandler } from '../classes/handlers/enrol-handler';
 | 
				
			||||||
 | 
					import { CORE_SITE_PLUGINS_COMPONENT } from '../constants';
 | 
				
			||||||
const HANDLER_DISABLED = 'core_site_plugins_helper_handler_disabled';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Helper service to provide functionalities regarding site plugins. It basically has the features to load and register site
 | 
					 * Helper service to provide functionalities regarding site plugins. It basically has the features to load and register site
 | 
				
			||||||
@ -102,7 +100,7 @@ const HANDLER_DISABLED = 'core_site_plugins_helper_handler_disabled';
 | 
				
			|||||||
 * inside the host DOM element?
 | 
					 * inside the host DOM element?
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@Injectable({ providedIn: 'root' })
 | 
					@Injectable({ providedIn: 'root' })
 | 
				
			||||||
export class CoreSitePluginsHelperProvider {
 | 
					export class CoreSitePluginsInitService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected logger: CoreLogger;
 | 
					    protected logger: CoreLogger;
 | 
				
			||||||
    protected courseRestrictHandlers: Record<string, {
 | 
					    protected courseRestrictHandlers: Record<string, {
 | 
				
			||||||
@ -112,21 +110,23 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
        handler: CoreSitePluginsCourseOptionHandler | CoreSitePluginsUserProfileHandler;
 | 
					        handler: CoreSitePluginsCourseOptionHandler | CoreSitePluginsUserProfileHandler;
 | 
				
			||||||
    }> = {};
 | 
					    }> = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected static readonly HANDLER_DISABLED = 'core_site_plugins_helper_handler_disabled';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor() {
 | 
					    constructor() {
 | 
				
			||||||
        this.logger = CoreLogger.getInstance('CoreSitePluginsHelperProvider');
 | 
					        this.logger = CoreLogger.getInstance('CoreSitePluginsInit');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Initialize.
 | 
					     * Initialize.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    initialize(): void {
 | 
					    init(): void {
 | 
				
			||||||
        // Fetch the plugins on login.
 | 
					        // Fetch the plugins on login.
 | 
				
			||||||
        CoreEvents.on(CoreEvents.LOGIN, async (data) => {
 | 
					        CoreEvents.on(CoreEvents.LOGIN, async (data) => {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                const plugins = await CoreUtils.ignoreErrors(CoreSitePlugins.getPlugins(data.siteId));
 | 
					                const plugins = await CoreUtils.ignoreErrors(CoreSitePlugins.getPlugins(data.siteId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Plugins fetched, check that site hasn't changed.
 | 
					                // Plugins fetched, check that site hasn't changed.
 | 
				
			||||||
                if (data.siteId != CoreSites.getCurrentSiteId() || !plugins?.length) {
 | 
					                if (data.siteId !== CoreSites.getCurrentSiteId() || !plugins?.length) {
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -145,7 +145,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Re-load plugins restricted for courses when the list of user courses changes.
 | 
					        // Re-load plugins restricted for courses when the list of user courses changes.
 | 
				
			||||||
        CoreEvents.on(CoreCoursesProvider.EVENT_MY_COURSES_CHANGED, (data) => {
 | 
					        CoreEvents.on(CoreCoursesProvider.EVENT_MY_COURSES_CHANGED, (data) => {
 | 
				
			||||||
            if (data && data.siteId && data.siteId == CoreSites.getCurrentSiteId() && data.added && data.added.length) {
 | 
					            if (data.siteId && data.siteId === CoreSites.getCurrentSiteId() && data.added.length) {
 | 
				
			||||||
                this.reloadCourseRestrictHandlers();
 | 
					                this.reloadCourseRestrictHandlers();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -160,7 +160,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     * @param siteId Site ID. If not provided, current site.
 | 
					     * @param siteId Site ID. If not provided, current site.
 | 
				
			||||||
     * @returns Promise resolved with the CSS code.
 | 
					     * @returns Promise resolved with the CSS code.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async downloadStyles(
 | 
					    protected async downloadStyles(
 | 
				
			||||||
        plugin: CoreSitePluginsPlugin,
 | 
					        plugin: CoreSitePluginsPlugin,
 | 
				
			||||||
        handlerName: string,
 | 
					        handlerName: string,
 | 
				
			||||||
        handlerSchema: CoreSitePluginsHandlerData,
 | 
					        handlerSchema: CoreSitePluginsHandlerData,
 | 
				
			||||||
@ -184,7 +184,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Remove the CSS files for this handler that aren't used anymore. Don't block the call for this.
 | 
					        // Remove the CSS files for this handler that aren't used anymore. Don't block the call for this.
 | 
				
			||||||
        const files = await CoreUtils.ignoreErrors(
 | 
					        const files = await CoreUtils.ignoreErrors(
 | 
				
			||||||
            CoreFilepool.getFilesByComponent(site.getId(), CoreSitePluginsProvider.COMPONENT, componentId),
 | 
					            CoreFilepool.getFilesByComponent(site.getId(), CORE_SITE_PLUGINS_COMPONENT, componentId),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        files?.forEach((file) => {
 | 
					        files?.forEach((file) => {
 | 
				
			||||||
@ -209,7 +209,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
            site.getId(),
 | 
					            site.getId(),
 | 
				
			||||||
            url,
 | 
					            url,
 | 
				
			||||||
            false,
 | 
					            false,
 | 
				
			||||||
            CoreSitePluginsProvider.COMPONENT,
 | 
					            CORE_SITE_PLUGINS_COMPONENT,
 | 
				
			||||||
            componentId,
 | 
					            componentId,
 | 
				
			||||||
            0,
 | 
					            0,
 | 
				
			||||||
            undefined,
 | 
					            undefined,
 | 
				
			||||||
@ -270,7 +270,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
        // Create a "fake" instance to hold all the libraries.
 | 
					        // Create a "fake" instance to hold all the libraries.
 | 
				
			||||||
        const instance = {
 | 
					        const instance = {
 | 
				
			||||||
            // eslint-disable-next-line @typescript-eslint/naming-convention
 | 
					            // eslint-disable-next-line @typescript-eslint/naming-convention
 | 
				
			||||||
            HANDLER_DISABLED: HANDLER_DISABLED,
 | 
					            HANDLER_DISABLED: CoreSitePluginsInitService.HANDLER_DISABLED,
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await CoreCompile.loadLibraries();
 | 
					        await CoreCompile.loadLibraries();
 | 
				
			||||||
@ -285,7 +285,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
        // Now execute the javascript using this instance.
 | 
					        // Now execute the javascript using this instance.
 | 
				
			||||||
        result.jsResult = CoreCompile.executeJavascript(instance, result.javascript);
 | 
					        result.jsResult = CoreCompile.executeJavascript(instance, result.javascript);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (result.jsResult == HANDLER_DISABLED) {
 | 
					        if (result.jsResult === CoreSitePluginsInitService.HANDLER_DISABLED) {
 | 
				
			||||||
            // The "disabled" field was added in 3.8, this is a workaround for previous versions.
 | 
					            // The "disabled" field was added in 3.8, this is a workaround for previous versions.
 | 
				
			||||||
            result.disabled = true;
 | 
					            result.disabled = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -311,10 +311,10 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     * Given an addon name and the key of a string, return the full string key (prefixed).
 | 
					     * Given an addon name and the key of a string, return the full string key (prefixed).
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param addon Name of the addon (plugin.addon).
 | 
					     * @param addon Name of the addon (plugin.addon).
 | 
				
			||||||
     * @param key The key of the string.
 | 
					     * @param key The key of the string. Defaults to pluginname.
 | 
				
			||||||
     * @returns Full string key.
 | 
					     * @returns Full string key.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected getPrefixedString(addon: string, key: string): string {
 | 
					    protected getPrefixedString(addon: string, key = 'pluginname'): string {
 | 
				
			||||||
        return this.getPrefixForStrings(addon) + key;
 | 
					        return this.getPrefixForStrings(addon) + key;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -323,7 +323,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param plugin Data of the plugin.
 | 
					     * @param plugin Data of the plugin.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    loadLangStrings(plugin: CoreSitePluginsPlugin): void {
 | 
					    protected loadLangStrings(plugin: CoreSitePluginsPlugin): void {
 | 
				
			||||||
        if (!plugin.parsedLang) {
 | 
					        if (!plugin.parsedLang) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -339,9 +339,8 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     * Load a site plugin.
 | 
					     * Load a site plugin.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param plugin Data of the plugin.
 | 
					     * @param plugin Data of the plugin.
 | 
				
			||||||
     * @returns Promise resolved when loaded.
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async loadSitePlugin(plugin: CoreSitePluginsPlugin): Promise<void> {
 | 
					    protected async loadSitePlugin(plugin: CoreSitePluginsPlugin): Promise<void> {
 | 
				
			||||||
        this.logger.debug('Load site plugin:', plugin);
 | 
					        this.logger.debug('Load site plugin:', plugin);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!plugin.parsedHandlers && plugin.handlers) {
 | 
					        if (!plugin.parsedHandlers && plugin.handlers) {
 | 
				
			||||||
@ -378,9 +377,8 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     * Load site plugins.
 | 
					     * Load site plugins.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param plugins The plugins to load.
 | 
					     * @param plugins The plugins to load.
 | 
				
			||||||
     * @returns Promise resolved when loaded.
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async loadSitePlugins(plugins: CoreSitePluginsPlugin[]): Promise<void> {
 | 
					    protected async loadSitePlugins(plugins: CoreSitePluginsPlugin[]): Promise<void> {
 | 
				
			||||||
        this.courseRestrictHandlers = {};
 | 
					        this.courseRestrictHandlers = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await CoreUtils.allPromises(plugins.map(async (plugin) => {
 | 
					        await CoreUtils.allPromises(plugins.map(async (plugin) => {
 | 
				
			||||||
@ -401,7 +399,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     * @param version Styles version.
 | 
					     * @param version Styles version.
 | 
				
			||||||
     * @param siteId Site ID. If not provided, current site.
 | 
					     * @param siteId Site ID. If not provided, current site.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    loadStyles(
 | 
					    protected loadStyles(
 | 
				
			||||||
        plugin: CoreSitePluginsPlugin,
 | 
					        plugin: CoreSitePluginsPlugin,
 | 
				
			||||||
        handlerName: string,
 | 
					        handlerName: string,
 | 
				
			||||||
        fileUrl: string,
 | 
					        fileUrl: string,
 | 
				
			||||||
@ -436,7 +434,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Styles have been loaded, now treat the CSS.
 | 
					        // Styles have been loaded, now treat the CSS.
 | 
				
			||||||
        CoreUtils.ignoreErrors(
 | 
					        CoreUtils.ignoreErrors(
 | 
				
			||||||
            CoreFilepool.treatCSSCode(siteId, fileUrl, cssCode, CoreSitePluginsProvider.COMPONENT, uniqueName, version),
 | 
					            CoreFilepool.treatCSSCode(siteId, fileUrl, cssCode, CORE_SITE_PLUGINS_COMPONENT, uniqueName, version),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -446,9 +444,8 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
     * @param plugin Data of the plugin.
 | 
					     * @param plugin Data of the plugin.
 | 
				
			||||||
     * @param handlerName Name of the handler in the plugin.
 | 
					     * @param handlerName Name of the handler in the plugin.
 | 
				
			||||||
     * @param handlerSchema Data about the handler.
 | 
					     * @param handlerSchema Data about the handler.
 | 
				
			||||||
     * @returns Promise resolved when done.
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    async registerHandler(
 | 
					    protected async registerHandler(
 | 
				
			||||||
        plugin: CoreSitePluginsPlugin,
 | 
					        plugin: CoreSitePluginsPlugin,
 | 
				
			||||||
        handlerName: string,
 | 
					        handlerName: string,
 | 
				
			||||||
        handlerSchema: CoreSitePluginsHandlerData,
 | 
					        handlerSchema: CoreSitePluginsHandlerData,
 | 
				
			||||||
@ -700,7 +697,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const blockName = (handlerSchema.moodlecomponent || plugin.component).replace('block_', '');
 | 
					        const blockName = (handlerSchema.moodlecomponent || plugin.component).replace('block_', '');
 | 
				
			||||||
        const titleString = handlerSchema.displaydata?.title ?? 'pluginname';
 | 
					        const titleString = handlerSchema.displaydata?.title;
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, titleString);
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, titleString);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CoreBlockDelegate.registerHandler(
 | 
					        CoreBlockDelegate.registerHandler(
 | 
				
			||||||
@ -761,7 +758,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Create and register the handler.
 | 
					        // Create and register the handler.
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title);
 | 
				
			||||||
        const handler = new CoreSitePluginsCourseOptionHandler(
 | 
					        const handler = new CoreSitePluginsCourseOptionHandler(
 | 
				
			||||||
            uniqueName,
 | 
					            uniqueName,
 | 
				
			||||||
            prefixedTitle,
 | 
					            prefixedTitle,
 | 
				
			||||||
@ -873,7 +870,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Create and register the handler.
 | 
					        // Create and register the handler.
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CoreMainMenuDelegate.registerHandler(
 | 
					        CoreMainMenuDelegate.registerHandler(
 | 
				
			||||||
            new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult),
 | 
					            new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult),
 | 
				
			||||||
@ -908,7 +905,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Create and register the handler.
 | 
					        // Create and register the handler.
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title);
 | 
				
			||||||
        const processorName = (handlerSchema.moodlecomponent || plugin.component).replace('message_', '');
 | 
					        const processorName = (handlerSchema.moodlecomponent || plugin.component).replace('message_', '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        AddonMessageOutputDelegate.registerHandler(
 | 
					        AddonMessageOutputDelegate.registerHandler(
 | 
				
			||||||
@ -1074,7 +1071,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Create and register the handler.
 | 
					        // Create and register the handler.
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CoreSettingsDelegate.registerHandler(
 | 
					        CoreSettingsDelegate.registerHandler(
 | 
				
			||||||
            new CoreSitePluginsSettingsHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult),
 | 
					            new CoreSitePluginsSettingsHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult),
 | 
				
			||||||
@ -1109,7 +1106,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Create and register the handler.
 | 
					        // Create and register the handler.
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title);
 | 
				
			||||||
        const handler = new CoreSitePluginsUserProfileHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult);
 | 
					        const handler = new CoreSitePluginsUserProfileHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CoreUserDelegate.registerHandler(handler);
 | 
					        CoreUserDelegate.registerHandler(handler);
 | 
				
			||||||
@ -1182,8 +1179,6 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Reload the handlers that are restricted to certain courses.
 | 
					     * Reload the handlers that are restricted to certain courses.
 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @returns Promise resolved when done.
 | 
					 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected async reloadCourseRestrictHandlers(): Promise<void> {
 | 
					    protected async reloadCourseRestrictHandlers(): Promise<void> {
 | 
				
			||||||
        if (!Object.keys(this.courseRestrictHandlers).length) {
 | 
					        if (!Object.keys(this.courseRestrictHandlers).length) {
 | 
				
			||||||
@ -1240,7 +1235,7 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // Create and register the handler.
 | 
					        // Create and register the handler.
 | 
				
			||||||
        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
					        const uniqueName = CoreSitePlugins.getHandlerUniqueName(plugin, handlerName);
 | 
				
			||||||
        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
 | 
					        const prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        CoreMainMenuHomeDelegate.registerHandler(
 | 
					        CoreMainMenuHomeDelegate.registerHandler(
 | 
				
			||||||
            new CoreSitePluginsMainMenuHomeHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult),
 | 
					            new CoreSitePluginsMainMenuHomeHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult),
 | 
				
			||||||
@ -1251,4 +1246,4 @@ export class CoreSitePluginsHelperProvider {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const CoreSitePluginsHelper = makeSingleton(CoreSitePluginsHelperProvider);
 | 
					export const CoreSitePluginsInit = makeSingleton(CoreSitePluginsInitService);
 | 
				
			||||||
@ -34,9 +34,7 @@ import { CorePlatform } from '@services/platform';
 | 
				
			|||||||
import { CoreEnrolAction, CoreEnrolInfoIcon } from '@features/enrol/services/enrol-delegate';
 | 
					import { CoreEnrolAction, CoreEnrolInfoIcon } from '@features/enrol/services/enrol-delegate';
 | 
				
			||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
					import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
 | 
				
			||||||
import { CoreUserProfileHandlerType } from '@features/user/services/user-delegate';
 | 
					import { CoreUserProfileHandlerType } from '@features/user/services/user-delegate';
 | 
				
			||||||
import { CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT } from '../constants';
 | 
					import { CORE_SITE_PLUGINS_COMPONENT, CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT } from '../constants';
 | 
				
			||||||
 | 
					 | 
				
			||||||
const ROOT_CACHE_KEY = 'CoreSitePlugins:';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Service to provide functionalities regarding site plugins.
 | 
					 * Service to provide functionalities regarding site plugins.
 | 
				
			||||||
@ -44,7 +42,14 @@ const ROOT_CACHE_KEY = 'CoreSitePlugins:';
 | 
				
			|||||||
@Injectable({ providedIn: 'root' })
 | 
					@Injectable({ providedIn: 'root' })
 | 
				
			||||||
export class CoreSitePluginsProvider {
 | 
					export class CoreSitePluginsProvider {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static readonly COMPONENT = 'CoreSitePlugins';
 | 
					    protected static readonly ROOT_CACHE_KEY = 'CoreSitePlugins:';
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @deprecated since 4.5.0. Use CORE_SITE_PLUGINS_COMPONENT instead.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    static readonly COMPONENT = CORE_SITE_PLUGINS_COMPONENT;
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @deprecated since 4.5.0. Use CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT instead.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    static readonly UPDATE_COURSE_CONTENT = CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT;
 | 
					    static readonly UPDATE_COURSE_CONTENT = CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected logger: CoreLogger;
 | 
					    protected logger: CoreLogger;
 | 
				
			||||||
@ -183,7 +188,7 @@ export class CoreSitePluginsProvider {
 | 
				
			|||||||
     * @returns Cache key.
 | 
					     * @returns Cache key.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected getCallWSCommonCacheKey(method: string): string {
 | 
					    protected getCallWSCommonCacheKey(method: string): string {
 | 
				
			||||||
        return ROOT_CACHE_KEY + 'ws:' + method;
 | 
					        return CoreSitePluginsProvider.ROOT_CACHE_KEY + 'ws:' + method;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -250,7 +255,8 @@ export class CoreSitePluginsProvider {
 | 
				
			|||||||
     * @returns Cache key.
 | 
					     * @returns Cache key.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected getContentCacheKey(component: string, method: string, args: Record<string, unknown>): string {
 | 
					    protected getContentCacheKey(component: string, method: string, args: Record<string, unknown>): string {
 | 
				
			||||||
        return ROOT_CACHE_KEY + 'content:' + component + ':' + method + ':' + CoreUtils.sortAndStringify(args);
 | 
					        return CoreSitePluginsProvider.ROOT_CACHE_KEY + 'content:' + component + ':' + method +
 | 
				
			||||||
 | 
					            ':' + CoreUtils.sortAndStringify(args);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -322,7 +328,7 @@ export class CoreSitePluginsProvider {
 | 
				
			|||||||
     * @returns Cache key.
 | 
					     * @returns Cache key.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected getPluginsCacheKey(): string {
 | 
					    protected getPluginsCacheKey(): string {
 | 
				
			||||||
        return ROOT_CACHE_KEY + 'plugins';
 | 
					        return CoreSitePluginsProvider.ROOT_CACHE_KEY + 'plugins';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
@ -20,12 +20,13 @@ import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-ro
 | 
				
			|||||||
import { CoreMainMenuHomeRoutingModule } from '@features/mainmenu/mainmenu-home-routing.module';
 | 
					import { CoreMainMenuHomeRoutingModule } from '@features/mainmenu/mainmenu-home-routing.module';
 | 
				
			||||||
import { CoreSitePreferencesRoutingModule } from '@features/settings/settings-site-routing.module';
 | 
					import { CoreSitePreferencesRoutingModule } from '@features/settings/settings-site-routing.module';
 | 
				
			||||||
import { CoreSitePluginsComponentsModule } from './components/components.module';
 | 
					import { CoreSitePluginsComponentsModule } from './components/components.module';
 | 
				
			||||||
import { CoreSitePluginsHelper } from './services/siteplugins-helper';
 | 
					import { CoreSitePluginsInit } from './services/siteplugins-init';
 | 
				
			||||||
import { CoreSharedModule } from '@/core/shared.module';
 | 
					import { CoreSharedModule } from '@/core/shared.module';
 | 
				
			||||||
import { CoreSitePluginsPluginPage } from '@features/siteplugins/pages/plugin/plugin';
 | 
					import { CoreSitePluginsPluginPage } from '@features/siteplugins/pages/plugin/plugin';
 | 
				
			||||||
import { canLeaveGuard } from '@guards/can-leave';
 | 
					import { canLeaveGuard } from '@guards/can-leave';
 | 
				
			||||||
import { CoreSitePluginsCourseOptionPage } from '@features/siteplugins/pages/course-option/course-option';
 | 
					import { CoreSitePluginsCourseOptionPage } from '@features/siteplugins/pages/course-option/course-option';
 | 
				
			||||||
import { CoreSitePluginsModuleIndexPage } from '@features/siteplugins/pages/module-index/module-index';
 | 
					import { CoreSitePluginsModuleIndexPage } from '@features/siteplugins/pages/module-index/module-index';
 | 
				
			||||||
 | 
					import { CORE_SITE_PLUGINS_PATH } from './constants';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Get site plugins exported objects.
 | 
					 * Get site plugins exported objects.
 | 
				
			||||||
@ -65,7 +66,7 @@ export async function getSitePluginsExportedObjects(): Promise<Record<string, un
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const routes: Routes = [
 | 
					const routes: Routes = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        path: 'siteplugins/content/:component/:method/:hash',
 | 
					        path: `${CORE_SITE_PLUGINS_PATH}/content/:component/:method/:hash`,
 | 
				
			||||||
        component: CoreSitePluginsPluginPage,
 | 
					        component: CoreSitePluginsPluginPage,
 | 
				
			||||||
        canDeactivate: [canLeaveGuard],
 | 
					        canDeactivate: [canLeaveGuard],
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -73,7 +74,7 @@ const routes: Routes = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const homeRoutes: Routes = [
 | 
					const homeRoutes: Routes = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        path: 'siteplugins/homecontent/:component/:method',
 | 
					        path: `${CORE_SITE_PLUGINS_PATH}/homecontent/:component/:method`,
 | 
				
			||||||
        component: CoreSitePluginsPluginPage,
 | 
					        component: CoreSitePluginsPluginPage,
 | 
				
			||||||
        canDeactivate: [canLeaveGuard],
 | 
					        canDeactivate: [canLeaveGuard],
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -81,7 +82,7 @@ const homeRoutes: Routes = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const courseIndexRoutes: Routes = [
 | 
					const courseIndexRoutes: Routes = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        path: 'siteplugins/:handlerUniqueName',
 | 
					        path: `${CORE_SITE_PLUGINS_PATH}/:handlerUniqueName`,
 | 
				
			||||||
        component: CoreSitePluginsCourseOptionPage,
 | 
					        component: CoreSitePluginsCourseOptionPage,
 | 
				
			||||||
        canDeactivate: [canLeaveGuard],
 | 
					        canDeactivate: [canLeaveGuard],
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -89,7 +90,7 @@ const courseIndexRoutes: Routes = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const moduleRoutes: Routes = [
 | 
					const moduleRoutes: Routes = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        path: 'siteplugins/module/:courseId/:cmId',
 | 
					        path: `${CORE_SITE_PLUGINS_PATH}/module/:courseId/:cmId`,
 | 
				
			||||||
        component: CoreSitePluginsModuleIndexPage,
 | 
					        component: CoreSitePluginsModuleIndexPage,
 | 
				
			||||||
        canDeactivate: [canLeaveGuard],
 | 
					        canDeactivate: [canLeaveGuard],
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
@ -114,7 +115,7 @@ const moduleRoutes: Routes = [
 | 
				
			|||||||
            provide: APP_INITIALIZER,
 | 
					            provide: APP_INITIALIZER,
 | 
				
			||||||
            multi: true,
 | 
					            multi: true,
 | 
				
			||||||
            useValue: () => {
 | 
					            useValue: () => {
 | 
				
			||||||
                CoreSitePluginsHelper.initialize();
 | 
					                CoreSitePluginsInit.init();
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user