Merge pull request #3858 from dpalou/MOBILE-4469

Mobile 4469
main
Noel De Martin 2023-11-22 11:37:59 +01:00 committed by GitHub
commit ba50fb8d6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
156 changed files with 2101 additions and 1622 deletions

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
import { CoreError } from '@classes/errors/error';

View File

@ -26,7 +26,7 @@ import { CoreCoursesHelper, CoreEnrolledCourseDataWithExtraInfoAndOptions } from
import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/services/course-helper';
import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate';
import { CoreBlockBaseComponent } from '@features/block/classes/base-block-component';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreUtils } from '@services/utils/utils';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';

View File

@ -30,7 +30,7 @@ import { CoreCourseOptionsDelegate } from '@features/course/services/course-opti
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
import { CoreBlockBaseComponent } from '@features/block/classes/base-block-component';
import { CoreUtils } from '@services/utils/utils';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
/**
* Component to render a recent courses block.

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreCourse } from '@features/course/services/course';
import { CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { makeSingleton } from '@singletons';
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';

View File

@ -24,7 +24,7 @@ import { CoreCourseOptionsDelegate } from '@features/course/services/course-opti
import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion';
import { CoreBlockBaseComponent } from '@features/block/classes/base-block-component';
import { CoreUtils } from '@services/utils/utils';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { AddonBlockStarredCourse, AddonBlockStarredCourses } from '../../services/starredcourses';
/**

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { makeSingleton } from '@singletons';
const ROOT_CACHE_KEY = 'AddonBlockStarredCourses:';

View File

@ -24,7 +24,7 @@ import {
} from '@addons/calendar/services/calendar';
import moment from 'moment-timezone';
import { makeSingleton } from '@singletons';
import { CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
// Cache key was maintained from block myoverview when blocks were splitted.
const ROOT_CACHE_KEY = 'myoverview:';

View File

@ -13,7 +13,8 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';

View File

@ -34,7 +34,7 @@ import {
import { AddonCalendarOffline } from '../../services/calendar-offline';
import { AddonCalendarEventTypeOption, AddonCalendarHelper } from '../../services/calendar-helper';
import { AddonCalendarSync, AddonCalendarSyncProvider } from '../../services/calendar-sync';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { Translate } from '@singletons';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { AddonCalendarOfflineEventDBRecord } from '../../services/database/calendar-offline';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreNetwork } from '@services/network';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
@ -50,6 +50,7 @@ import {
} from '@features/reminders/services/reminders';
import { CoreReminderDBRecord } from '@features/reminders/services/database/reminders';
import { CoreEvents } from '@singletons/events';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaCalendar:';

View File

@ -13,7 +13,8 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCommentsArea } from '@features/comments/services/comments';
import { CoreCourseSummary, CoreCourseModuleSummary } from '@features/course/services/course';
import { CoreUserSummary } from '@features/user/services/user';

View File

@ -17,12 +17,13 @@ import { CoreLogger } from '@singletons/logger';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreCourses } from '@features/courses/services/courses';
import { CoreSite, CoreSiteWSPreSets, WSObservable } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons';
import { CoreError } from '@classes/errors/error';
import { asyncObservable, firstValueFrom } from '@/core/utils/rxjs';
import { map } from 'rxjs/operators';
import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaCourseCompletion:';

View File

@ -13,7 +13,8 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreEnrolEnrolmentInfo } from '@features/enrol/services/enrol';
import { CoreSites } from '@services/sites';
import { CoreWSExternalWarning } from '@services/ws';

View File

@ -14,7 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreWSError } from '@classes/errors/wserror';
import { CoreSiteWSPreSets, CoreSite } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCoursesProvider } from '@features/courses/services/courses';
import { CoreSites } from '@services/sites';
import { CoreStatusWithWarningsWSResponse } from '@services/ws';

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -21,7 +21,7 @@ import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreEvents } from '@singletons/events';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreLang } from '@services/lang';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFilter, CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreFilterDefaultHandler } from '@features/filter/services/handlers/default-filter';
import { CoreFilterFormatTextOptions } from '@features/filter/services/filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreConstants } from '@/core/constants';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror';
import { makeSingleton, Translate } from '@singletons';
@ -25,6 +25,7 @@ import { CoreEvents, CoreEventSiteData } from '@singletons/events';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { CorePath } from '@singletons/path';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaMessageOutputAirnotifier:';

View File

@ -31,7 +31,7 @@ import { CoreConstants } from '@/core/constants';
import { CoreUser } from '@features/user/services/user';
import { CoreError } from '@classes/errors/error';
import { CoreTextErrorObject, CoreTextUtils } from '@services/utils/text';
import { CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
/**
* Service to sync messages.

View File

@ -26,13 +26,14 @@ import {
import { CoreUtils } from '@services/utils/utils';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreEvents } from '@singletons/events';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons';
import { CoreError } from '@classes/errors/error';
import { AddonMessagesSyncEvents, AddonMessagesSyncProvider } from './messages-sync';
import { CoreWSError } from '@classes/errors/wserror';
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaMessages:';

View File

@ -15,7 +15,7 @@
import { Component, Optional, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { Params } from '@angular/router';
import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
import { IonContent } from '@ionic/angular';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreInterceptor } from '@classes/interceptor';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
@ -35,6 +35,7 @@ import { AddonModAssignAutoSyncData, AddonModAssignManualSyncData, AddonModAssig
import { CoreFormFields } from '@singletons/form';
import { CoreFileHelper } from '@services/file-helper';
import { CoreIonicColorNames } from '@singletons/colors';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModAssign:';

View File

@ -15,7 +15,8 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWS } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
@ -26,6 +26,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreFile } from '@services/file';
import { CoreError } from '@classes/errors/error';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
/**
* Constants to define how the chapters and subchapters of a book should be displayed in that table of contents.

View File

@ -14,7 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreUser } from '@features/user/services/user';

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreNetwork } from '@services/network';
@ -26,6 +26,7 @@ import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWar
import { makeSingleton, Translate } from '@singletons';
import { AddonModChoiceOffline } from './choice-offline';
import { AddonModChoiceAutoSyncData, AddonModChoiceSyncProvider } from './choice-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModChoice:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreRatingInfo } from '@features/rating/services/rating';
@ -29,6 +29,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldsDelegate } from './data-fields-delegate';
import { AddonModDataOffline } from './data-offline';
import { AddonModDataAutoSyncData, AddonModDataSyncProvider } from './data-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModData:';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourse, CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CanLeave } from '@guards/can-leave';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreNetwork } from '@services/network';
@ -25,6 +25,7 @@ import { CoreWSExternalFile, CoreWSExternalWarning, CoreWSStoredFile } from '@se
import { makeSingleton, Translate } from '@singletons';
import { AddonModFeedbackOffline } from './feedback-offline';
import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'AddonModFeedback:';

View File

@ -14,7 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';

View File

@ -86,7 +86,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit {
*/
protected setOpenInBrowserUrl(): void {
const site = CoreSites.getRequiredCurrentSite();
if (!CoreSites.shouldDisplayInformativeLinks(site)) {
if (!site.shouldDisplayInformativeLinks()) {
return;
}

View File

@ -167,7 +167,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
const currentSite = CoreSites.getCurrentSite();
this.isOnline = CoreNetwork.isOnline();
this.externalUrl = currentSite && CoreSites.shouldDisplayInformativeLinks(currentSite) ?
this.externalUrl = currentSite && currentSite.shouldDisplayInformativeLinks() ?
currentSite.createSiteUrl('/mod/forum/discuss.php', { d: this.discussionId.toString() }) :
undefined;
this.onlineObserver = CoreNetwork.onChange().subscribe(() => {

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreRatingInfo } from '@features/rating/services/rating';
@ -29,6 +29,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning, CoreWSStoredFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModForumOffline, AddonModForumOfflineDiscussion, AddonModForumReplyOptions } from './forum-offline';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModForum:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
@ -28,6 +28,7 @@ import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModGlossaryEntryDBRecord, ENTRIES_TABLE_NAME } from './database/glossary';
import { AddonModGlossaryOffline } from './glossary-offline';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
export const GLOSSARY_ENTRY_ADDED = 'addon_mod_glossary_entry_added';
export const GLOSSARY_ENTRY_UPDATED = 'addon_mod_glossary_entry_updated';

View File

@ -16,7 +16,7 @@ import { Component, Optional, OnInit, OnDestroy, Output, EventEmitter } from '@a
import { IonContent } from '@ionic/angular';
import { CoreConstants } from '@/core/constants';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
import { CoreH5PDisplayOptions } from '@features/h5p/classes/core';

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { CoreUtils } from '@services/utils/utils';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreH5P } from '@features/h5p/services/h5p';
import { CoreH5PDisplayOptions } from '@features/h5p/classes/core';
@ -27,6 +27,7 @@ import { CoreWSError } from '@classes/errors/wserror';
import { CoreError } from '@classes/errors/error';
import { AddonModH5PActivityAutoSyncData, AddonModH5PActivitySyncProvider } from './h5pactivity-sync';
import { CoreTime } from '@singletons/time';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
export const MOD_H5PACTIVITY_STATE_ID = 'state';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
@ -26,6 +26,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CorePath } from '@singletons/path';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModImscp:';

View File

@ -14,7 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreGradesProvider } from '@features/grades/services/grades';
@ -28,6 +28,7 @@ import { CoreEvents } from '@singletons/events';
import { AddonModLessonPasswordDBRecord, PASSWORD_TABLE_NAME } from './database/lesson';
import { AddonModLessonOffline, AddonModLessonPageAttemptRecord } from './lesson-offline';
import { AddonModLessonAutoSyncData, AddonModLessonSyncProvider } from './lesson-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModLesson:';

View File

@ -15,7 +15,8 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFile } from '@services/file';
import { CorePlatform } from '@services/platform';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreFilepool } from '@services/filepool';
@ -22,6 +22,7 @@ import { CoreCourse } from '@features/course/services/course';
import { CoreUtils } from '@services/utils/utils';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreError } from '@classes/errors/error';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModPage:';

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper';
@ -40,6 +40,7 @@ import { AddonModQuizAccessRuleDelegate } from './access-rules-delegate';
import { AddonModQuizAttempt } from './quiz-helper';
import { AddonModQuizOffline, AddonModQuizQuestionsWithAnswers } from './quiz-offline';
import { AddonModQuizAutoSyncData, AddonModQuizSyncProvider } from './quiz-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModQuiz:';

View File

@ -14,7 +14,8 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFilepool } from '@services/filepool';

View File

@ -15,7 +15,7 @@
import { CoreConstants } from '@/core/constants';
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFilepool } from '@services/filepool';
@ -31,6 +31,7 @@ import { CoreEvents } from '@singletons/events';
import { CorePath } from '@singletons/path';
import { AddonModScormOffline } from './scorm-offline';
import { AddonModScormAutoSyncEventData, AddonModScormSyncProvider } from './scorm-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
// Private constants.
const VALID_STATUSES = ['notattempted', 'passed', 'completed', 'failed', 'incomplete', 'browsed', 'suspend'];

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreNetwork } from '@services/network';
@ -24,6 +24,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonModSurveyOffline } from './survey-offline';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModSurvey:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { CoreConstants } from '@/core/constants';
@ -23,6 +23,7 @@ import { CoreCourse } from '@features/course/services/course';
import { CoreUtils } from '@services/utils/utils';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreError } from '@classes/errors/error';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModUrl:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreTagItem } from '@features/tag/services/tag';
@ -28,6 +28,7 @@ import { CoreEvents } from '@singletons/events';
import { AddonModWikiPageDBRecord } from './database/wiki';
import { AddonModWikiOffline } from './wiki-offline';
import { AddonModWikiAutoSyncData, AddonModWikiManualSyncData, AddonModWikiSyncProvider } from './wiki-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModWiki:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
@ -28,6 +28,7 @@ import { CoreFormFields } from '@singletons/form';
import { AddonModWorkshopOffline } from './workshop-offline';
import { AddonModWorkshopAutoSyncData, AddonModWorkshopSyncProvider } from './workshop-sync';
import { ADDON_MOD_WORKSHOP_COMPONENT } from '@addons/mod/workshop/constants';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaModWorkshop:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreWSError } from '@classes/errors/wserror';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreUser } from '@features/user/services/user';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
@ -22,6 +22,7 @@ import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalWarning } from '@services/ws';
import { makeSingleton, Translate } from '@singletons';
import { AddonNotesOffline } from './notes-offline';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmaNotes:';

View File

@ -19,11 +19,12 @@ import { CoreWSExternalWarning } from '@services/ws';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUser, USER_NOREPLY_USER } from '@features/user/services/user';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreLogger } from '@singletons/logger';
import { Translate, makeSingleton } from '@singletons';
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
import { AddonNotificationsPushNotification } from './handlers/push-click';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
declare module '@singletons/events' {

View File

@ -17,7 +17,7 @@ import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
const ROOT_CACHE_KEY = 'mmaFiles:';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreConstants } from '@/core/constants';
import { CoreSitePublicConfigResponse } from '@classes/site';
import { CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site';
import { CoreFile } from '@services/file';
import { CoreFilepool } from '@services/filepool';
import { CoreSites } from '@services/sites';

View File

@ -15,7 +15,7 @@
import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreWSError } from '@classes/errors/wserror';

View File

@ -14,7 +14,7 @@
import { CoreSites } from '@services/sites';
import { CoreEvents } from '@singletons/events';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreLogger } from '@singletons/logger';
/**

View File

@ -18,7 +18,7 @@ import { Subscription } from 'rxjs';
import { AsyncDirective } from './async-directive';
import { PageLoadsManager } from './page-loads-manager';
import { CorePromisedValue } from './promised-value';
import { WSObservable } from './site';
import { WSObservable } from './sites/authenticated-site';
/**
* Class to watch requests from a page load (including requests from page sub-components).

View File

@ -0,0 +1,964 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { InAppBrowserObject, InAppBrowserOptions } from '@ionic-native/in-app-browser';
import { CoreNetwork } from '@services/network';
import { CoreDB } from '@services/db';
import { CoreEventData, CoreEvents } from '@singletons/events';
import { CoreFile } from '@services/file';
import {
CoreWS,
CoreWSFileUploadOptions,
CoreWSExternalWarning,
CoreWSUploadFileResult,
} from '@services/ws';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils, CoreUtilsOpenInBrowserOptions } from '@services/utils/utils';
import { CoreConstants } from '@/core/constants';
import { SQLiteDB } from '@classes/sqlitedb';
import { CoreError } from '@classes/errors/error';
import { CoreLogger } from '@singletons/logger';
import { Translate } from '@singletons';
import { CoreIonLoadingElement } from '../ion-loading';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { asyncInstance, AsyncInstance } from '../../utils/async-instance';
import { CoreDatabaseTable } from '../database/database-table';
import { CoreDatabaseCachingStrategy } from '../database/database-table-proxy';
import {
CONFIG_TABLE,
CoreSiteConfigDBRecord,
CoreSiteLastViewedDBRecord,
CoreSiteWSCacheRecord,
LAST_VIEWED_TABLE,
WS_CACHE_TABLE,
} from '@services/database/sites';
import { map } from 'rxjs/operators';
import { firstValueFrom } from '../../utils/rxjs';
import { CoreFilepool } from '@services/filepool';
import { CoreSiteInfo } from './unauthenticated-site';
import { CoreAuthenticatedSite, CoreAuthenticatedSiteOptionalData, CoreSiteWSPreSets, WSObservable } from './authenticated-site';
/**
* Class that represents a site (combination of site + user).
* It will have all the site data and provide utility functions regarding a site.
*/
export class CoreSite extends CoreAuthenticatedSite {
id: string;
config?: CoreSiteConfig;
loggedOut?: boolean;
protected db!: SQLiteDB;
protected cacheTable: AsyncInstance<CoreDatabaseTable<CoreSiteWSCacheRecord>>;
protected configTable: AsyncInstance<CoreDatabaseTable<CoreSiteConfigDBRecord, 'name'>>;
protected lastViewedTable: AsyncInstance<CoreDatabaseTable<CoreSiteLastViewedDBRecord, 'component' | 'id'>>;
protected lastAutoLogin = 0;
protected tokenPluginFileWorks?: boolean;
protected tokenPluginFileWorksPromise?: Promise<boolean>;
protected oauthId?: number;
/**
* Create a site.
*
* @param id Site ID.
* @param siteUrl Site URL.
* @param token Site's WS token.
* @param otherData Other data.
*/
constructor(
id: string,
siteUrl: string,
token: string,
otherData: CoreSiteOptionalData = {},
) {
super(siteUrl, token, otherData);
this.id = id;
this.config = otherData.config;
this.loggedOut = otherData.loggedOut;
this.logger = CoreLogger.getInstance('CoreSite');
this.cacheTable = asyncInstance(() => CoreSites.getSiteTable(WS_CACHE_TABLE, {
siteId: this.getId(),
database: this.getDb(),
config: { cachingStrategy: CoreDatabaseCachingStrategy.None },
}));
this.configTable = asyncInstance(() => CoreSites.getSiteTable(CONFIG_TABLE, {
siteId: this.getId(),
database: this.getDb(),
config: { cachingStrategy: CoreDatabaseCachingStrategy.Eager },
primaryKeyColumns: ['name'],
}));
this.lastViewedTable = asyncInstance(() => CoreSites.getSiteTable(LAST_VIEWED_TABLE, {
siteId: this.getId(),
database: this.getDb(),
config: { cachingStrategy: CoreDatabaseCachingStrategy.Eager },
primaryKeyColumns: ['component', 'id'],
}));
this.setInfo(otherData.info);
this.calculateOfflineDisabled();
this.db = CoreDB.getDB('Site-' + this.id);
}
/**
* Get site ID.
*
* @returns Site ID.
*/
getId(): string {
return this.id;
}
/**
* Get site DB.
*
* @returns Site DB.
*/
getDb(): SQLiteDB {
return this.db;
}
/**
* Check if user logged out from the site and needs to authenticate again.
*
* @returns Whether is logged out.
*/
isLoggedOut(): boolean {
return !!this.loggedOut;
}
/**
* Get OAuth ID.
*
* @returns OAuth ID.
*/
getOAuthId(): number | undefined {
return this.oauthId;
}
/**
* Set site config.
*
* @param config Config.
*/
setConfig(config: CoreSiteConfig): void {
if (config) {
config.tool_mobile_disabledfeatures = CoreTextUtils.treatDisabledFeatures(config.tool_mobile_disabledfeatures);
}
this.config = config;
this.calculateOfflineDisabled();
}
/**
* Set site logged out.
*
* @param loggedOut True if logged out and needs to authenticate again, false otherwise.
*/
setLoggedOut(loggedOut: boolean): void {
this.loggedOut = !!loggedOut;
}
/**
* Set OAuth ID.
*
* @param oauthId OAuth ID.
*/
setOAuthId(oauthId: number | undefined): void {
this.oauthId = oauthId;
}
/**
* Check if the user authenticated in the site using an OAuth method.
*
* @returns Whether the user authenticated in the site using an OAuth method.
*/
isOAuth(): boolean {
return this.oauthId != null && this.oauthId !== undefined;
}
/**
* @inheritdoc
*/
protected async getCacheEntryById(id: string): Promise<CoreSiteWSCacheRecord> {
return this.cacheTable.getOneByPrimaryKey({ id });
}
/**
* @inheritdoc
*/
protected async getCacheEntriesByKey(key: string): Promise<CoreSiteWSCacheRecord[]> {
return this.cacheTable.getMany({ key });
}
/**
* @inheritdoc
*/
protected async storeCacheEntry(entry: CoreSiteWSCacheRecord): Promise<void> {
await this.cacheTable.insert(entry);
}
/**
* @inheritdoc
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected async deleteFromCache(method: string, data: any, preSets: CoreSiteWSPreSets, allCacheKey?: boolean): Promise<void> {
if (allCacheKey) {
await this.cacheTable.delete({ key: preSets.cacheKey });
} else {
await this.cacheTable.deleteByPrimaryKey({ id: this.getCacheId(method, data) });
}
}
/**
* Gets the size of cached data for a specific component or component instance.
*
* @param component Component name
* @param componentId Optional component id (if not included, returns sum for whole component)
* @returns Promise resolved when we have calculated the size
*/
async getComponentCacheSize(component: string, componentId?: number): Promise<number> {
const params: Array<string | number> = [component];
let extraClause = '';
if (componentId !== undefined && componentId !== null) {
params.push(componentId);
extraClause = ' AND componentId = ?';
}
return this.cacheTable.reduce(
{
sql: 'SUM(length(data))',
js: (size, record) => size + record.data.length,
jsInitialValue: 0,
},
{
sql: 'WHERE component = ?' + extraClause,
sqlParams: params,
js: record => record.component === component && (params.length === 1 || record.componentId === componentId),
},
);
}
/**
* Deletes WS cache entries for all methods relating to a specific component (and
* optionally component id).
*
* @param component Component name.
* @param componentId Component id.
* @returns Promise resolved when the entries are deleted.
*/
async deleteComponentFromCache(component: string, componentId?: number): Promise<void> {
if (!component) {
return;
}
const params = { component };
if (componentId) {
params['componentId'] = componentId;
}
await this.cacheTable.delete(params);
}
/*
* Uploads a file using Cordova File API.
*
* @param filePath File path.
* @param options File upload options.
* @param onProgress Function to call on progress.
* @returns Promise resolved when uploaded.
*/
uploadFile(
filePath: string,
options: CoreWSFileUploadOptions,
onProgress?: (event: ProgressEvent) => void,
): Promise<CoreWSUploadFileResult> {
if (!options.fileArea) {
options.fileArea = 'draft';
}
return CoreWS.uploadFile(filePath, options, {
siteUrl: this.siteUrl,
wsToken: this.token || '',
}, onProgress);
}
/**
* Invalidates all caches related to the site.
*/
async invalidateCaches(): Promise<void> {
await Promise.all([
CoreFilepool.invalidateAllFiles(this.getId()),
this.invalidateWsCache(),
]);
}
/**
* @inheritdoc
*/
async invalidateWsCache(): Promise<void> {
this.logger.debug('Invalidate all the cache for site: ' + this.id);
try {
await this.cacheTable.update({ expirationTime: 0 });
} finally {
CoreEvents.trigger(CoreEvents.WS_CACHE_INVALIDATED, {}, this.getId());
}
}
/**
* @inheritdoc
*/
async invalidateWsCacheForKey(key: string): Promise<void> {
if (!key) {
return;
}
this.logger.debug('Invalidate cache for key: ' + key);
await this.cacheTable.update({ expirationTime: 0 }, { key });
}
/**
* @inheritdoc
*/
async invalidateWsCacheForKeyStartingWith(key: string): Promise<void> {
if (!key) {
return;
}
this.logger.debug('Invalidate cache for key starting with: ' + key);
await this.cacheTable.updateWhere({ expirationTime: 0 }, {
sql: 'key LIKE ?',
sqlParams: [key + '%'],
js: record => !!record.key?.startsWith(key),
});
}
/**
* Check if tokenpluginfile can be used, and fix the URL afterwards.
*
* @param url The url to be fixed.
* @returns Promise resolved with the fixed URL.
*/
checkAndFixPluginfileURL(url: string): Promise<string> {
return this.checkTokenPluginFile(url).then(() => this.fixPluginfileURL(url));
}
/**
* Generic function for adding the wstoken to Moodle urls and for pointing to the correct script.
* Uses CoreUtilsProvider.fixPluginfileURL, passing site's token.
*
* @param url The url to be fixed.
* @returns Fixed URL.
*/
fixPluginfileURL(url: string): string {
const accessKey = this.tokenPluginFileWorks || this.tokenPluginFileWorks === undefined ?
this.infos && this.infos.userprivateaccesskey : undefined;
return CoreUrlUtils.fixPluginfileURL(url, this.token || '', this.siteUrl, accessKey);
}
/**
* Deletes site's DB.
*
* @returns Promise to be resolved when the DB is deleted.
*/
async deleteDB(): Promise<void> {
await CoreDB.deleteDB('Site-' + this.id);
}
/**
* Deletes site's folder.
*
* @returns Promise to be resolved when the DB is deleted.
*/
async deleteFolder(): Promise<void> {
if (!CoreFile.isAvailable() || !this.id) {
return;
}
const siteFolder = CoreFile.getSiteFolder(this.id);
// Ignore any errors, removeDir fails if folder doesn't exists.
await CoreUtils.ignoreErrors(CoreFile.removeDir(siteFolder));
}
/**
* Get space usage of the site.
*
* @returns Promise resolved with the site space usage (size).
*/
getSpaceUsage(): Promise<number> {
if (CoreFile.isAvailable() && this.id) {
const siteFolderPath = CoreFile.getSiteFolder(this.id);
return CoreFile.getDirectorySize(siteFolderPath).catch(() => 0);
} else {
return Promise.resolve(0);
}
}
/**
* Gets an approximation of the cache table usage of the site.
*
* Currently this is just the total length of the data fields in the cache table.
*
* @returns Promise resolved with the total size of all data in the cache table (bytes)
*/
async getCacheUsage(): Promise<number> {
return this.cacheTable.reduce({
sql: 'SUM(length(data))',
js: (size, record) => size + record.data.length,
jsInitialValue: 0,
});
}
/**
* Gets a total of the file and cache usage.
*
* @returns Promise with the total of getSpaceUsage and getCacheUsage
*/
async getTotalUsage(): Promise<number> {
const space = await this.getSpaceUsage();
const cache = await this.getCacheUsage();
return space + cache;
}
/**
* Check if GET method is supported for AJAX calls.
*
* @returns Whether it's supported.
*/
protected isAjaxGetSupported(): boolean {
return !!this.getInfo() && this.isVersionGreaterEqualThan('3.8');
}
/**
* Open a URL in browser using auto-login in the Moodle site if available.
*
* @param url The URL to open.
* @param alertMessage If defined, an alert will be shown before opening the browser.
* @param options Other options.
* @returns Promise resolved when done, rejected otherwise.
*/
async openInBrowserWithAutoLogin(
url: string,
alertMessage?: string,
options: CoreUtilsOpenInBrowserOptions = {},
): Promise<void> {
await this.openWithAutoLogin(false, url, options, alertMessage);
}
/**
* Open a URL in browser using auto-login in the Moodle site if available and the URL belongs to the site.
*
* @param url The URL to open.
* @param alertMessage If defined, an alert will be shown before opening the browser.
* @param options Other options.
* @returns Promise resolved when done, rejected otherwise.
* @deprecated since 4.1. Use openInBrowserWithAutoLogin instead, now it always checks that URL belongs to same site.
*/
async openInBrowserWithAutoLoginIfSameSite(
url: string,
alertMessage?: string,
options: CoreUtilsOpenInBrowserOptions = {},
): Promise<void> {
return this.openInBrowserWithAutoLogin(url, alertMessage, options);
}
/**
* Open a URL in inappbrowser using auto-login in the Moodle site if available.
*
* @param url The URL to open.
* @param options Override default options passed to InAppBrowser.
* @param alertMessage If defined, an alert will be shown before opening the inappbrowser.
* @returns Promise resolved when done.
*/
async openInAppWithAutoLogin(url: string, options?: InAppBrowserOptions, alertMessage?: string): Promise<InAppBrowserObject> {
const iabInstance = <InAppBrowserObject> await this.openWithAutoLogin(true, url, options, alertMessage);
return iabInstance;
}
/**
* Open a URL in inappbrowser using auto-login in the Moodle site if available and the URL belongs to the site.
*
* @param url The URL to open.
* @param options Override default options passed to inappbrowser.
* @param alertMessage If defined, an alert will be shown before opening the inappbrowser.
* @returns Promise resolved when done.
* @deprecated since 4.1. Use openInAppWithAutoLogin instead, now it always checks that URL belongs to same site.
*/
async openInAppWithAutoLoginIfSameSite(
url: string,
options?: InAppBrowserOptions,
alertMessage?: string,
): Promise<InAppBrowserObject> {
return this.openInAppWithAutoLogin(url, options, alertMessage);
}
/**
* Open a URL in browser or InAppBrowser using auto-login in the Moodle site if available.
*
* @param inApp True to open it in InAppBrowser, false to open in browser.
* @param url The URL to open.
* @param options Override default options passed to $cordovaInAppBrowser#open.
* @param alertMessage If defined, an alert will be shown before opening the browser/inappbrowser.
* @returns Promise resolved when done. Resolve param is returned only if inApp=true.
*/
async openWithAutoLogin(
inApp: boolean,
url: string,
options: InAppBrowserOptions & CoreUtilsOpenInBrowserOptions = {},
alertMessage?: string,
): Promise<InAppBrowserObject | void> {
// Get the URL to open.
const autoLoginUrl = await this.getAutoLoginUrl(url);
if (alertMessage) {
// Show an alert first.
const alert = await CoreDomUtils.showAlert(
Translate.instant('core.notice'),
alertMessage,
undefined,
3000,
);
await alert.onDidDismiss();
options.showBrowserWarning = false; // A warning already shown, no need to show another.
}
options.originalUrl = url;
// Open the URL.
if (inApp) {
return CoreUtils.openInApp(autoLoginUrl, options);
} else {
return CoreUtils.openInBrowser(autoLoginUrl, options);
}
}
/**
* Open a URL in browser or InAppBrowser using auto-login in the Moodle site if available and the URL belongs to the site.
*
* @param inApp True to open it in InAppBrowser, false to open in browser.
* @param url The URL to open.
* @param options Override default options passed to inappbrowser.
* @param alertMessage If defined, an alert will be shown before opening the browser/inappbrowser.
* @returns Promise resolved when done. Resolve param is returned only if inApp=true.
* @deprecated since 4.1. Use openWithAutoLogin instead, now it always checks that URL belongs to same site.
*/
async openWithAutoLoginIfSameSite(
inApp: boolean,
url: string,
options: InAppBrowserOptions & CoreUtilsOpenInBrowserOptions = {},
alertMessage?: string,
): Promise<InAppBrowserObject | void> {
return this.openWithAutoLogin(inApp, url, options, alertMessage);
}
/**
* Get the config of this site.
* It is recommended to use getStoredConfig instead since it's faster and doesn't use network.
*
* @param name Name of the setting to get. If not set or false, all settings will be returned.
* @param ignoreCache True if it should ignore cached data.
* @returns Promise resolved with site config.
*/
getConfig(name?: undefined, ignoreCache?: boolean): Promise<CoreSiteConfig>;
getConfig(name: string, ignoreCache?: boolean): Promise<string>;
getConfig(name?: string, ignoreCache?: boolean): Promise<string | CoreSiteConfig> {
return firstValueFrom(
this.getConfigObservable(<string> name, ignoreCache ? CoreSitesReadingStrategy.ONLY_NETWORK : undefined),
);
}
/**
* Get the config of this site.
* It is recommended to use getStoredConfig instead since it's faster and doesn't use network.
*
* @param name Name of the setting to get. If not set or false, all settings will be returned.
* @param readingStrategy Reading strategy.
* @returns Observable returning site config.
*/
getConfigObservable(name?: undefined, readingStrategy?: CoreSitesReadingStrategy): WSObservable<CoreSiteConfig>;
getConfigObservable(name: string, readingStrategy?: CoreSitesReadingStrategy): WSObservable<string>;
getConfigObservable(name?: string, readingStrategy?: CoreSitesReadingStrategy): WSObservable<string | CoreSiteConfig> {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getConfigCacheKey(),
...CoreSites.getReadingStrategyPreSets(readingStrategy),
};
return this.readObservable<CoreSiteConfigResponse>('tool_mobile_get_config', {}, preSets).pipe(map(config => {
if (name) {
// Return the requested setting.
for (const x in config.settings) {
if (config.settings[x].name == name) {
return String(config.settings[x].value);
}
}
throw new CoreError('Site config not found: ' + name);
} else {
// Return all settings in the same array.
const settings: CoreSiteConfig = {};
config.settings.forEach((setting) => {
settings[setting.name] = String(setting.value);
});
return settings;
}
}));
}
/**
* Invalidates config WS call.
*
* @returns Promise resolved when the data is invalidated.
*/
async invalidateConfig(): Promise<void> {
await this.invalidateWsCacheForKey(this.getConfigCacheKey());
}
/**
* Get cache key for getConfig WS calls.
*
* @returns Cache key.
*/
protected getConfigCacheKey(): string {
return 'tool_mobile_get_config';
}
/**
* Get the stored config of this site.
*
* @param name Name of the setting to get. If not set, all settings will be returned.
* @returns Site config or a specific setting.
*/
getStoredConfig(): CoreSiteConfig | undefined;
getStoredConfig(name: string): string | undefined;
getStoredConfig(name?: string): string | CoreSiteConfig | undefined {
if (!this.config) {
return;
}
if (name) {
return this.config[name];
} else {
return this.config;
}
}
/**
* @inheritdoc
*/
protected getDisabledFeatures(): string | undefined {
return this.config ? this.getStoredConfig('tool_mobile_disabledfeatures') : super.getDisabledFeatures();
}
/**
* @inheritdoc
*/
protected triggerSiteEvent<Fallback = unknown, Event extends string = string>(
eventName: Event,
data?: CoreEventData<Event, Fallback>,
): void {
CoreEvents.trigger(eventName, data, this.id);
}
/**
* Calculate if offline is disabled in the site.
*/
calculateOfflineDisabled(): void {
this.offlineDisabled = this.isFeatureDisabled('NoDelegate_CoreOffline');
}
/**
* Get whether offline is disabled in the site.
*
* @returns Whether it's disabled.
*/
isOfflineDisabled(): boolean {
return this.offlineDisabled;
}
/**
* Given a URL, convert it to a URL that will auto-login if supported.
*
* @param url The URL to convert.
* @param showModal Whether to show a loading modal.
* @returns Promise resolved with the converted URL.
*/
async getAutoLoginUrl(url: string, showModal: boolean = true): Promise<string> {
if (!this.privateToken) {
// No private token, don't change the URL.
return url;
}
if (!this.containsUrl(url)) {
// URL doesn't belong to the site, don't auto login.
return url;
}
if (this.lastAutoLogin > 0) {
const timeBetweenRequests = await CoreUtils.ignoreErrors(
this.getConfig('tool_mobile_autologinmintimebetweenreq'),
CoreConstants.SECONDS_MINUTE * 6,
);
if (CoreTimeUtils.timestamp() - this.lastAutoLogin < Number(timeBetweenRequests)) {
// Not enough time has passed since last auto login.
return url;
}
}
const userId = this.getUserId();
const params = {
privatetoken: this.privateToken,
};
let modal: CoreIonLoadingElement | undefined;
if (showModal) {
modal = await CoreDomUtils.showModalLoading();
}
try {
// Use write to not use cache.
const data = await this.write<CoreSiteAutologinKeyResult>('tool_mobile_get_autologin_key', params);
if (!data.autologinurl || !data.key) {
// Not valid data, return the same URL.
return url;
}
this.lastAutoLogin = CoreTimeUtils.timestamp();
return data.autologinurl + '?userid=' + userId + '&key=' + data.key + '&urltogo=' + encodeURIComponent(url);
} catch (error) {
// Couldn't get autologin key, return the same URL.
return url;
} finally {
modal?.dismiss();
}
}
/**
* Deletes a site setting.
*
* @param name The config name.
* @returns Promise resolved when done.
*/
async deleteSiteConfig(name: string): Promise<void> {
await this.configTable.deleteByPrimaryKey({ name });
}
/**
* Get a site setting on local device.
*
* @param name The config name.
* @param defaultValue Default value to use if the entry is not found.
* @returns Resolves upon success along with the config data. Reject on failure.
*/
async getLocalSiteConfig<T extends number | string>(name: string, defaultValue?: T): Promise<T> {
try {
const entry = await this.configTable.getOneByPrimaryKey({ name });
return <T> entry.value;
} catch (error) {
if (defaultValue !== undefined) {
return defaultValue;
}
throw error;
}
}
/**
* Set a site setting on local device.
*
* @param name The config name.
* @param value The config value. Can only store number or strings.
* @returns Promise resolved when done.
*/
async setLocalSiteConfig(name: string, value: number | string): Promise<void> {
await this.configTable.insert({ name, value });
}
/*
* Check if tokenpluginfile script works in the site.
*
* @param url URL to check.
* @returns Promise resolved with boolean: whether it works or not.
*/
checkTokenPluginFile(url: string): Promise<boolean> {
if (!CoreUrlUtils.canUseTokenPluginFile(url, this.siteUrl, this.infos && this.infos.userprivateaccesskey)) {
// Cannot use tokenpluginfile.
return Promise.resolve(false);
} else if (this.tokenPluginFileWorks !== undefined) {
// Already checked.
return Promise.resolve(this.tokenPluginFileWorks);
} else if (this.tokenPluginFileWorksPromise) {
// Check ongoing, use the same promise.
return this.tokenPluginFileWorksPromise;
} else if (!CoreNetwork.isOnline()) {
// Not online, cannot check it. Assume it's working, but don't save the result.
return Promise.resolve(true);
}
url = this.fixPluginfileURL(url);
this.tokenPluginFileWorksPromise = CoreWS.urlWorks(url).then((result) => {
this.tokenPluginFileWorks = result;
return result;
});
return this.tokenPluginFileWorksPromise;
}
/**
* Deletes last viewed records based on some conditions.
*
* @param conditions Conditions.
* @returns Promise resolved when done.
*/
async deleteLastViewed(conditions?: Partial<CoreSiteLastViewedDBRecord>): Promise<void> {
await this.lastViewedTable.delete(conditions);
}
/**
* Get a last viewed record for a component+id.
*
* @param component The component.
* @param id ID.
* @returns Resolves with last viewed record, undefined if not found.
*/
async getLastViewed(component: string, id: number): Promise<CoreSiteLastViewedDBRecord | undefined> {
try {
return await this.lastViewedTable.getOneByPrimaryKey({ component, id });
} catch {
// Not found.
}
}
/**
* Get several last viewed for a certain component.
*
* @param component The component.
* @param ids IDs. If not provided or empty, return all last viewed for a component.
* @returns Resolves with last viewed records, undefined if error.
*/
async getComponentLastViewed(component: string, ids: number[] = []): Promise<CoreSiteLastViewedDBRecord[] | undefined> {
try {
if (!ids.length) {
return await this.lastViewedTable.getMany({ component });
}
const whereAndParams = SQLiteDB.getInOrEqual(ids);
whereAndParams.sql = 'id ' + whereAndParams.sql + ' AND component = ?';
whereAndParams.params.push(component);
return await this.lastViewedTable.getManyWhere({
sql: whereAndParams.sql,
sqlParams: whereAndParams.params,
js: (record) => record.component === component && ids.includes(record.id),
});
} catch {
// Not found.
}
}
/**
* Store a last viewed record.
*
* @param component The component.
* @param id ID.
* @param value Last viewed item value.
* @param options Options.
* @returns Promise resolved when done.
*/
async storeLastViewed(
component: string,
id: number,
value: string | number,
options: CoreSiteStoreLastViewedOptions = {},
): Promise<void> {
await this.lastViewedTable.insert({
component,
id,
value: String(value),
data: options.data,
timeaccess: options.timeaccess ?? Date.now(),
});
}
}
/**
* Optional data to create a site.
*/
export type CoreSiteOptionalData = CoreAuthenticatedSiteOptionalData & {
info?: CoreSiteInfo;
config?: CoreSiteConfig;
loggedOut?: boolean;
};
/**
* Result of WS tool_mobile_get_config.
*/
export type CoreSiteConfigResponse = {
settings: { // Settings.
name: string; // The name of the setting.
value: string | number; // The value of the setting.
}[];
warnings?: CoreWSExternalWarning[];
};
/**
* Site config indexed by name.
*/
export type CoreSiteConfig = Record<string, string> & {
supportavailability?: string; // String representation of CoreSiteConfigSupportAvailability.
searchbanner?: string; // Search banner text.
searchbannerenable?: string; // Whether search banner is enabled.
};
/**
* Result of WS tool_mobile_get_autologin_key.
*/
export type CoreSiteAutologinKeyResult = {
key: string; // Auto-login key for a single usage with time expiration.
autologinurl: string; // Auto-login URL.
warnings?: CoreWSExternalWarning[];
};
/**
* Options for storeLastViewed.
*/
export type CoreSiteStoreLastViewedOptions = {
data?: string; // Other data.
timeaccess?: number; // Accessed time. If not set, current time.
};

View File

@ -0,0 +1,483 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { CoreConstants } from '@/core/constants';
import { CoreError } from '@classes/errors/error';
import { CoreLoginHelper } from '@features/login/services/login-helper';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreWS, CoreWSAjaxPreSets, CoreWSExternalWarning } from '@services/ws';
import { CorePath } from '@singletons/path';
/**
* Class that represents a Moodle site where the user still hasn't authenticated.
*/
export class CoreUnauthenticatedSite {
siteUrl: string;
protected publicConfig?: CoreSitePublicConfigResponse;
/**
* Create a site.
*
* @param siteUrl Site URL.
* @param publicConfig Site public config.
*/
constructor(siteUrl: string, publicConfig?: CoreSitePublicConfigResponse) {
this.siteUrl = CoreUrlUtils.removeUrlParams(siteUrl); // Make sure the URL doesn't have params.
if (publicConfig) {
this.setPublicConfig(publicConfig);
}
}
/**
* Get site URL.
*
* @returns Site URL.
*/
getURL(): string {
return this.siteUrl;
}
/**
* Set site URL.
*
* @param url Site URL.
*/
setURL(url: string): void {
this.siteUrl = url;
}
/**
* Get site info.
*
* @returns Site info.
*/
getInfo(): CoreSiteInfo | undefined {
// Cannot retrieve info for unauthenticated sites.
return undefined;
}
/**
* Check if the site has info with the given key and it doesn't contain an empty value.
*
* @param key Info key.
* @returns Whether the key is filled within site info.
*/
hasInfo(key: string): boolean {
const info = this.getInfo()?.[key] ?? null;
return info === false || info === 0 || !!info;
}
/**
* Get site name.
*
* @returns Site name.
*/
async getSiteName(): Promise<string> {
if (this.isDemoModeSite()) {
return CoreConstants.CONFIG.appname;
}
const siteName = this.getInfo()?.sitename || this.publicConfig?.sitename;
if (siteName) {
return siteName;
}
// Fallback.
const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite();
if (isSingleFixedSite) {
const sites = await CoreLoginHelper.getAvailableSites();
return sites[0].name;
}
return '';
}
/**
* Check whether the app should use the local logo instead of the remote one.
*
* @returns Whether local logo is forced.
*/
forcesLocalLogo(): boolean {
return CoreConstants.CONFIG.forceLoginLogo || this.isDemoModeSite();
}
/**
* Get logo URL from a site public config.
*
* @param config Site public config.
* @returns Logo URL.
*/
getLogoUrl(config?: CoreSitePublicConfigResponse): string | undefined {
config = config ?? this.publicConfig;
if (!config || this.forcesLocalLogo()) {
return 'assets/img/login_logo.png';
}
return config.logourl || config.compactlogourl || 'assets/img/login_logo.png';
}
/**
* Returns a url to link an specific page on the site.
*
* @param path Path of the url to go to.
* @param params Object with the params to add.
* @param anchor Anchor text if needed.
* @returns URL with params.
*/
createSiteUrl(path: string, params?: Record<string, unknown>, anchor?: string): string {
return CoreUrlUtils.addParamsToUrl(CorePath.concatenatePaths(this.siteUrl, path), params, anchor);
}
/**
* Check if a URL belongs to this site.
*
* @param url URL to check.
* @returns Whether the URL belongs to this site.
*/
containsUrl(url?: string): boolean {
if (!url) {
return false;
}
const siteUrl = CoreTextUtils.addEndingSlash(CoreUrlUtils.removeProtocolAndWWW(this.siteUrl));
url = CoreTextUtils.addEndingSlash(CoreUrlUtils.removeProtocolAndWWW(url));
return url.indexOf(siteUrl) == 0;
}
/**
* Get the public config of this site.
*
* @param options Options.
* @returns Promise resolved with public config. Rejected with an object if error, see CoreWSProvider.callAjax.
*/
async getPublicConfig(options: { readingStrategy?: CoreSitesReadingStrategy } = {}): Promise<CoreSitePublicConfigResponse> {
const ignoreCache = options.readingStrategy === CoreSitesReadingStrategy.ONLY_NETWORK ||
options.readingStrategy === CoreSitesReadingStrategy.PREFER_NETWORK;
if (!ignoreCache && this.publicConfig) {
return this.publicConfig;
};
if (options.readingStrategy === CoreSitesReadingStrategy.ONLY_CACHE) {
throw new CoreError('Cache not available to read public config');
}
try {
const config = await this.requestPublicConfig();
this.setPublicConfig(config);
return config;
} catch (error) {
if (options.readingStrategy === CoreSitesReadingStrategy.ONLY_NETWORK || !this.publicConfig) {
throw error;
}
return this.publicConfig;
}
}
/**
* Set public config.
*
* @param publicConfig Public config.
*/
setPublicConfig(publicConfig: CoreSitePublicConfigResponse): void {
publicConfig.tool_mobile_disabledfeatures =
CoreTextUtils.treatDisabledFeatures(publicConfig.tool_mobile_disabledfeatures ?? '');
this.publicConfig = publicConfig;
}
/**
* Perform a request to the server to get the public config of this site.
*
* @returns Promise resolved with public config.
*/
protected async requestPublicConfig(): Promise<CoreSitePublicConfigResponse> {
const preSets: CoreWSAjaxPreSets = {
siteUrl: this.siteUrl,
};
let config: CoreSitePublicConfigResponse;
try {
config = await CoreWS.callAjax<CoreSitePublicConfigResponse>('tool_mobile_get_public_config', {}, preSets);
} catch (error) {
if (!error || error.errorcode !== 'codingerror' || (this.getInfo() && !this.isAjaxGetSupported())) {
throw error;
}
// This error probably means that there is a redirect in the site. Try to use a GET request.
preSets.noLogin = true;
preSets.useGet = true;
try {
config = await CoreWS.callAjax<CoreSitePublicConfigResponse>('tool_mobile_get_public_config', {}, preSets);
} catch (error2) {
if (this.isAjaxGetSupported()) {
// GET is supported, return the second error.
throw error2;
} else {
// GET not supported or we don't know if it's supported. Return first error.
throw error;
}
}
}
// Use the wwwroot returned by the server.
if (config.httpswwwroot) {
this.siteUrl = CoreUrlUtils.removeUrlParams(config.httpswwwroot); // Make sure the URL doesn't have params.
}
return config;
}
/**
* Check if GET method is supported for AJAX calls.
*
* @returns Whether it's supported.
* @since Moodle 3.8
*/
protected isAjaxGetSupported(): boolean {
// We don't know if it's supported, assume it's not.
return false;
}
/**
* Check if a URL to a file belongs to the site and uses the pluginfileurl or tokenpluginfileurl endpoints.
*
* @param url File URL to check.
* @returns Whether it's a site file URL.
*/
isSitePluginFileUrl(url: string): boolean {
const isPluginFileUrl = CoreUrlUtils.isPluginFileUrl(url) || CoreUrlUtils.isTokenPluginFileUrl(url);
if (!isPluginFileUrl) {
return false;
}
return this.containsUrl(url);
}
/**
* Check if a URL to a file belongs to the site and is a theme image file.
*
* @param url File URL to check.
* @returns Whether it's a site theme image URL.
*/
isSiteThemeImageUrl(url: string): boolean {
if (!CoreUrlUtils.isThemeImageUrl(url)) {
return false;
}
return this.containsUrl(url);
}
/**
* Check if the site is a demo mode site.
*
* @returns Whether the site is a demo mode site.
*/
isDemoModeSite(): boolean {
const demoSiteData = CoreLoginHelper.getDemoModeSiteInfo();
return this.containsUrl(demoSiteData?.url);
}
/**
* Check whether informative links should be displayed for this site.
*
* @returns Whether informative links should be displayed.
*/
shouldDisplayInformativeLinks(): boolean {
return !CoreConstants.CONFIG.hideInformativeLinks && !this.isDemoModeSite();
}
/**
* Check if a certain feature is disabled in the site.
*
* @param name Name of the feature to check.
* @returns Whether it's disabled.
*/
isFeatureDisabled(name: string): boolean {
const disabledFeatures = this.getDisabledFeatures();
if (!disabledFeatures) {
return false;
}
const regEx = new RegExp('(,|^)' + CoreTextUtils.escapeForRegex(name) + '(,|$)', 'g');
return !!disabledFeatures.match(regEx);
}
/**
* Get disabled features string.
*
* @returns Disabled features.
*/
protected getDisabledFeatures(): string | undefined {
return this.publicConfig?.tool_mobile_disabledfeatures;
}
}
/**
* Result of WS core_webservice_get_site_info.
*/
export type CoreSiteInfoResponse = {
sitename: string; // Site name.
username: string; // Username.
firstname: string; // First name.
lastname: string; // Last name.
fullname: string; // User full name.
lang: string; // Current language.
userid: number; // User id.
siteurl: string; // Site url.
userpictureurl: string; // The user profile picture.
functions: {
name: string; // Function name.
version: string; // The version number of the component to which the function belongs.
}[];
downloadfiles?: number; // 1 if users are allowed to download files, 0 if not.
uploadfiles?: number; // 1 if users are allowed to upload files, 0 if not.
release?: string; // Moodle release number.
version?: string; // Moodle version number.
mobilecssurl?: string; // Mobile custom CSS theme.
advancedfeatures?: { // Advanced features availability.
name: string; // Feature name.
value: number; // Feature value. Usually 1 means enabled.
}[];
usercanmanageownfiles?: boolean; // True if the user can manage his own files.
userquota?: number; // User quota (bytes). 0 means user can ignore the quota.
usermaxuploadfilesize?: number; // User max upload file size (bytes). -1 means the user can ignore the upload file size.
userhomepage?: CoreSiteInfoUserHomepage; // The default home page for the user.
userprivateaccesskey?: string; // Private user access key for fetching files.
siteid?: number; // Site course ID.
sitecalendartype?: string; // Calendar type set in the site.
usercalendartype?: string; // Calendar typed used by the user.
userissiteadmin?: boolean; // Whether the user is a site admin or not.
theme?: string; // Current theme for the user.
};
/**
* Site info, including some calculated data.
*/
export type CoreSiteInfo = CoreSiteInfoResponse & {
functionsByName?: {
[name: string]: {
name: string; // Function name.
version: string; // The version number of the component to which the function belongs.
};
};
};
/**
* Enum constants that define default user home page.
*/
export enum CoreSiteInfoUserHomepage {
HOMEPAGE_SITE = 0, // Site home.
HOMEPAGE_MY = 1, // Dashboard.
HOMEPAGE_MYCOURSES = 3, // My courses.
}
/**
* Possible values for 'supportavailability' config.
*/
export const enum CoreSiteConfigSupportAvailability {
Disabled = 0,
Authenticated = 1,
Anyone = 2,
}
/**
* Result of WS tool_mobile_get_public_config.
*/
export type CoreSitePublicConfigResponse = {
wwwroot: string; // Site URL.
httpswwwroot: string; // Site https URL (if httpslogin is enabled).
sitename: string; // Site name.
guestlogin: number; // Whether guest login is enabled.
rememberusername: number; // Values: 0 for No, 1 for Yes, 2 for optional.
authloginviaemail: number; // Whether log in via email is enabled.
registerauth: string; // Authentication method for user registration.
forgottenpasswordurl: string; // Forgotten password URL.
authinstructions: string; // Authentication instructions.
authnoneenabled: number; // Whether auth none is enabled.
enablewebservices: number; // Whether Web Services are enabled.
enablemobilewebservice: number; // Whether the Mobile service is enabled.
maintenanceenabled: number; // Whether site maintenance is enabled.
maintenancemessage: string; // Maintenance message.
logourl?: string; // The site logo URL.
compactlogourl?: string; // The site compact logo URL.
typeoflogin: TypeOfLogin; // The type of login. 1 for app, 2 for browser, 3 for embedded.
launchurl?: string; // SSO login launch URL.
mobilecssurl?: string; // Mobile custom CSS theme.
// eslint-disable-next-line @typescript-eslint/naming-convention
tool_mobile_disabledfeatures?: string; // Disabled features in the app.
identityproviders?: CoreSiteIdentityProvider[]; // Identity providers.
country?: string; // Default site country.
agedigitalconsentverification?: boolean; // Whether age digital consent verification is enabled.
supportname?: string; // Site support contact name (only if age verification is enabled).
supportemail?: string; // Site support contact email (only if age verification is enabled).
supportavailability?: CoreSiteConfigSupportAvailability;
supportpage?: string; // Site support contact url.
autolang?: number; // Whether to detect default language from browser setting.
lang?: string; // Default language for the site.
langmenu?: number; // Whether the language menu should be displayed.
langlist?: string; // Languages on language menu.
locale?: string; // Sitewide locale.
// eslint-disable-next-line @typescript-eslint/naming-convention
tool_mobile_minimumversion?: string; // Minimum required version to access.
// eslint-disable-next-line @typescript-eslint/naming-convention
tool_mobile_iosappid?: string; // IOS app's unique identifier.
// eslint-disable-next-line @typescript-eslint/naming-convention
tool_mobile_androidappid?: string; // Android app's unique identifier.
// eslint-disable-next-line @typescript-eslint/naming-convention
tool_mobile_setuplink?: string; // App download page.
tool_mobile_qrcodetype?: CoreSiteQRCodeType; // eslint-disable-line @typescript-eslint/naming-convention
warnings?: CoreWSExternalWarning[];
};
/**
* QR Code type enumeration.
*/
export enum CoreSiteQRCodeType {
QR_CODE_DISABLED = 0, // QR code disabled value
QR_CODE_URL = 1, // QR code type URL value
QR_CODE_LOGIN = 2, // QR code type login value
}
/**
* Identity provider.
*/
export type CoreSiteIdentityProvider = {
name: string; // The identity provider name.
iconurl: string; // The icon URL for the provider.
url: string; // The URL of the provider.
};
/**
* The type of login. 1 for app, 2 for browser, 3 for embedded.
*/
export enum TypeOfLogin {
APP = 1,
BROWSER = 2, // SSO in browser window is required.
EMBEDDED = 3, // SSO in embedded browser is required.
}

View File

@ -14,8 +14,9 @@
import { Component, ContentChild, Input, Output, TemplateRef, EventEmitter } from '@angular/core';
import { CoreSiteBasicInfo, CoreSites } from '@services/sites';
import { CoreSiteBasicInfo } from '@services/sites';
import { CoreAccountsList } from '@features/login/services/login-helper';
import { CoreSitesFactory } from '@services/sites-factory';
/**
* Component to display a list of sites (accounts).
@ -84,7 +85,7 @@ export class CoreSitesListComponent<T extends CoreSiteBasicInfo> {
* @returns Whether to display URL.
*/
displaySiteUrl(site: CoreSiteBasicInfo): boolean {
return CoreSites.shouldDisplayInformativeLinks(site.siteUrl);
return CoreSitesFactory.makeSite(site.id, site.siteUrl, '', { info: site.info }).shouldDisplayInformativeLinks();
}
}

View File

@ -22,7 +22,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreNetwork } from '@services/network';
import { CoreUserHelper } from '@features/user/services/user-helper';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreSiteInfo } from '@classes/site';
import { CoreSiteInfo } from '@classes/sites/unauthenticated-site';
/**
* Component to display a "user avatar".

View File

@ -30,7 +30,7 @@ import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreLogger } from '@singletons/logger';
import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreConstants } from '../constants';
import { CoreNetwork } from '@services/network';

View File

@ -34,7 +34,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreIframeUtils, CoreIframeUtilsProvider } from '@services/utils/iframe';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { NgZone, Translate } from '@singletons';
import { CoreExternalContentDirective } from './external-content';
import { CoreLinkDirective } from './link';

View File

@ -21,7 +21,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreFilter } from '@features/filter/services/filter';
import { CoreFilterHelper } from '@features/filter/services/filter-helper';
import { CoreFormatTextDirective } from '@directives/format-text';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CorePlatform } from '@services/platform';
import { CoreSites } from '@services/sites';
import { CoreStorage } from '@services/storage';

View File

@ -15,7 +15,7 @@
import { Injectable, Type } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { Subject } from 'rxjs';
import { CoreCourseBlock } from '@features/course/services/course';
import { Params } from '@angular/router';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreNetwork } from '@services/network';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
@ -23,6 +23,7 @@ import { makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { CoreCommentsOffline } from './comments-offline';
import { CoreCommentsSyncAutoSyncData, CoreCommentsSyncProvider } from './comments-sync';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmComments:';

View File

@ -20,6 +20,7 @@ import { CoreContentLinksAction } from '../../services/contentlinks-delegate';
import { CoreContentLinksHelper } from '../../services/contentlinks-helper';
import { CoreError } from '@classes/errors/error';
import { CoreNavigator } from '@services/navigator';
import { CoreSitesFactory } from '@services/sites-factory';
/**
* Page to display the list of sites to choose one to perform a content link action.
@ -73,7 +74,7 @@ export class CoreContentLinksChooseSiteModalComponent implements OnInit {
this.sites = await CoreSites.getSites(siteIds);
// All sites have the same URL, use the first one.
this.displaySiteUrl = CoreSites.shouldDisplayInformativeLinks(this.sites[0].siteUrl);
this.displaySiteUrl = CoreSitesFactory.makeUnauthenticatedSite(this.sites[0].siteUrl).shouldDisplayInformativeLinks();
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'core.contentlinks.errornosites', true);
this.closeModal();

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreContentLinksDelegate, CoreContentLinksAction } from './contentlinks-delegate';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton, Translate } from '@singletons';
import { CoreNavigator } from '@services/navigator';
import { CoreContentLinksChooseSiteModalComponent } from '../components/choose-site-modal/choose-site-modal';

View File

@ -101,7 +101,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
}
this.displayOptions = Object.assign({
displayOpenInBrowser: CoreSites.shouldDisplayInformativeLinks(),
displayOpenInBrowser: !!CoreSites.getCurrentSite()?.shouldDisplayInformativeLinks(),
displayDescription: true,
displayRefresh: true,
displayPrefetch: true,

View File

@ -138,7 +138,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy {
const currentSiteUrl = CoreSites.getRequiredCurrentSite().getURL();
this.enrolUrl = CorePath.concatenatePaths(currentSiteUrl, 'enrol/index.php?id=' + this.courseId);
this.courseUrl = CorePath.concatenatePaths(currentSiteUrl, 'course/view.php?id=' + this.courseId);
this.displayOpenInBrowser = CoreSites.shouldDisplayInformativeLinks();
this.displayOpenInBrowser = CoreSites.getRequiredCurrentSite().shouldDisplayInformativeLinks();
await this.getCourse();
}

View File

@ -63,7 +63,7 @@ export class CoreCourseModulePreviewPage implements OnInit {
return;
}
this.displayOpenInBrowser = CoreSites.shouldDisplayInformativeLinks();
this.displayOpenInBrowser = !!CoreSites.getCurrentSite()?.shouldDisplayInformativeLinks();
this.debouncedUpdateModule = CoreUtils.debounce(() => {
this.doRefresh();
}, 10000);

View File

@ -58,7 +58,7 @@ import {
import { CoreFileSizeSum } from '@services/plugin-file-delegate';
import { CoreFileHelper } from '@services/file-helper';
import { CoreNetwork } from '@services/network';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreFile } from '@services/file';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreTextUtils } from '@services/utils/text';

View File

@ -21,7 +21,7 @@ import { CoreLogger } from '@singletons/logger';
import { CoreSitesCommonWSOptions, CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreSiteWSPreSets, CoreSite, WSObservable } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreConstants } from '@/core/constants';
import { makeSingleton, Translate } from '@singletons';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
@ -55,6 +55,7 @@ import { SQLiteDB } from '@classes/sqlitedb';
import { CorePlatform } from '@services/platform';
import { asyncObservable, firstValueFrom } from '@/core/utils/rxjs';
import { map } from 'rxjs/operators';
import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmCourse:';

View File

@ -15,7 +15,7 @@
import { Injectable, Type } from '@angular/core';
import { SafeUrl } from '@angular/platform-browser';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseModuleDefaultHandler } from './handlers/default-module';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { CoreCourseAnyCourseData } from '@features/courses/services/courses';

View File

@ -24,7 +24,7 @@ import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils';
import { CoreCourse, CoreCourseAnyModuleData, CoreCourseModuleContentFile } from './course';
import { CoreCache } from '@classes/cache';
import { CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreConstants } from '@/core/constants';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { makeSingleton } from '@singletons';

View File

@ -29,7 +29,7 @@ import moment from 'moment-timezone';
import { of } from 'rxjs';
import { firstValueFrom, zipIncludingComplete } from '@/core/utils/rxjs';
import { catchError, map } from 'rxjs/operators';
import { chainRequests, WSObservable } from '@classes/site';
import { chainRequests, WSObservable } from '@classes/sites/authenticated-site';
// Id for a course item representing all courses (for example, for course filters).
export const ALL_COURSES_ID = -1;

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets, WSObservable } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
import { CoreWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { CoreEvents } from '@singletons/events';
@ -25,6 +25,7 @@ import { map } from 'rxjs/operators';
import { AddonEnrolGuest, AddonEnrolGuestInfo } from '@addons/enrol/guest/services/guest';
import { AddonEnrolSelf } from '@addons/enrol/self/services/self';
import { CoreEnrol, CoreEnrolEnrolmentInfo, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol';
import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'mmCourses:';

View File

@ -14,13 +14,14 @@
import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets, WSObservable } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseBlock } from '@features/course/services/course';
import { CoreStatusWithWarningsWSResponse } from '@services/ws';
import { makeSingleton } from '@singletons';
import { CoreError } from '@classes/errors/error';
import { map } from 'rxjs/operators';
import { asyncObservable, firstValueFrom } from '@/core/utils/rxjs';
import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site';
const ROOT_CACHE_KEY = 'CoreCoursesDashboard:';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreSiteInfoUserHomepage } from '@classes/site';
import { CoreSiteInfoUserHomepage } from '@classes/sites/unauthenticated-site';
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate';
import { CoreSiteHomeHomeHandler } from '@features/sitehome/services/handlers/sitehome-home';
import { CoreSites } from '@services/sites';

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
import { makeSingleton } from '@singletons';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreEnrolAction, CoreEnrolDelegate } from './enrol-delegate';

View File

@ -28,7 +28,7 @@ import { CoreWSFile, CoreWSFileUploadOptions, CoreWSUploadFileResult } from '@se
import { makeSingleton, Translate, MediaCapture, Camera } from '@singletons';
import { CoreLogger } from '@singletons/logger';
import { CoreError } from '@classes/errors/error';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
import { CorePath } from '@singletons/path';
import { CorePlatform } from '@services/platform';

View File

@ -18,7 +18,7 @@ import { CoreSites } from '@services/sites';
import { CoreFilterFilter, CoreFilterFormatTextOptions } from './filter';
import { CoreFilterDefaultHandler } from './handlers/default-filter';
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { makeSingleton } from '@singletons';
/**

View File

@ -29,7 +29,7 @@ import { CoreCourses } from '@features/courses/services/courses';
import { makeSingleton } from '@singletons';
import { CoreEvents, CoreEventSiteData } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreCourseHelper } from '@features/course/services/course-helper';
import { firstValueFrom } from '@/core/utils/rxjs';

View File

@ -16,13 +16,14 @@ import { Injectable } from '@angular/core';
import { CoreNetwork } from '@services/network';
import { CoreSites, CoreSitesReadingStrategy } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreTextUtils } from '@services/utils/text';
import { CoreFilterDelegate } from './filter-delegate';
import { makeSingleton } from '@singletons';
import { CoreEvents, CoreEventSiteData } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
/**
* Service to provide filter functionalities.

View File

@ -16,7 +16,7 @@ import { Injectable, ViewContainerRef } from '@angular/core';
import { CoreFilterHandler } from '../filter-delegate';
import { CoreFilterFilter, CoreFilterFormatTextOptions } from '../filter';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
/**
* Default handler used when the module doesn't have a specific implementation.

View File

@ -18,7 +18,7 @@ import { CoreSites } from '@services/sites';
import { makeSingleton } from '@singletons';
import { CoreLogger } from '@singletons/logger';
import { CoreWSExternalWarning } from '@services/ws';
import { CoreSiteWSPreSets } from '@classes/site';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
import { CoreError } from '@classes/errors/error';
import { SafeNumber } from '@/core/utils/types';

View File

@ -25,7 +25,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreH5P } from '@features/h5p/services/h5p';
import { CoreConstants } from '@/core/constants';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreLogger } from '@singletons/logger';
import { CoreH5PCore, CoreH5PDisplayOptions } from '../../classes/core';
import { CoreH5PHelper } from '../../classes/helper';

View File

@ -21,7 +21,7 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUrlUtils } from '@services/utils/url';
import { CorePluginFileDelegate } from '@services/plugin-file-delegate';
import { CoreConstants } from '@/core/constants';
import { CoreSite } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreEvents, CoreEventObserver } from '@singletons/events';
import { CoreLogger } from '@singletons/logger';
import { CoreH5P } from '@features/h5p/services/h5p';

View File

@ -18,7 +18,7 @@ import { CoreSites } from '@services/sites';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreQueueRunner } from '@classes/queue-runner';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreSite } from '@classes/sites/site';
import { CoreH5PCore } from '../classes/core';
import { CoreH5PFramework } from '../classes/framework';
@ -29,6 +29,7 @@ import { CoreH5PValidator } from '../classes/validator';
import { makeSingleton } from '@singletons';
import { CoreError } from '@classes/errors/error';
import { CorePath } from '@singletons/path';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
/**
* Service to provide H5P functionalities.

View File

@ -13,10 +13,11 @@
// limitations under the License.
import { Component, Input, OnInit } from '@angular/core';
import { CoreSiteIdentityProvider, CoreSitePublicConfigResponse } from '@classes/site';
import { CoreSiteIdentityProvider, CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site';
import { CoreLoginHelper, CoreLoginMethod } from '@features/login/services/login-helper';
import { CoreRedirectPayload } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { CoreSitesFactory } from '@services/sites-factory';
import { CoreDomUtils } from '@services/utils/dom';
@Component({
@ -53,11 +54,11 @@ export class CoreLoginMethodsComponent implements OnInit {
if (this.siteConfig) {
this.isBrowserSSO = CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin);
// Identity providers won't be shown if login on browser.
if (!this.isBrowserSSO) {
// Identity providers won't be shown if login on browser.
const disabledFeatures = CoreLoginHelper.getDisabledFeatures(this.siteConfig);
this.identityProviders = CoreLoginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures);
this.identityProviders = await CoreLoginHelper.getValidIdentityProvidersForSite(
CoreSitesFactory.makeUnauthenticatedSite(this.siteUrl, this.siteConfig),
);
}
if (this.reconnect) {

View File

@ -16,7 +16,7 @@ import { AfterViewInit, Component, ElementRef, HostBinding, OnDestroy } from '@a
import { CoreUtils } from '@services/utils/utils';
import { ModalController, Translate } from '@singletons';
import { CoreLoginHelperProvider, GET_STARTED_URL } from '@features/login/services/login-helper';
import { FAQ_QRCODE_IMAGE_HTML, FAQ_URL_IMAGE_HTML, GET_STARTED_URL } from '@features/login/constants';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreCancellablePromise } from '@classes/cancellable-promise';
@ -39,8 +39,8 @@ export class CoreLoginSiteHelpComponent implements AfterViewInit, OnDestroy {
constructor(protected el: ElementRef<HTMLElement>) {
const getStartedTitle = Translate.instant('core.login.faqsetupsitelinktitle');
const canScanQR = CoreUtils.canScanQR();
const urlImageHtml = CoreLoginHelperProvider.FAQ_URL_IMAGE_HTML;
const qrCodeImageHtml = CoreLoginHelperProvider.FAQ_QRCODE_IMAGE_HTML;
const urlImageHtml = FAQ_URL_IMAGE_HTML;
const qrCodeImageHtml = FAQ_QRCODE_IMAGE_HTML;
const setupLinkHtml = `<a href="${GET_STARTED_URL}" title="${getStartedTitle}">${GET_STARTED_URL}</a>`;
const questions: Array<QuestionDefinition | false> = [
{

Some files were not shown because too many files have changed in this diff Show More