From d06e9ec1db8472df4a8ba0d1faf9e6e8103c176b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 18 Oct 2024 12:09:42 +0200 Subject: [PATCH 1/2] MOBILE-4616 search: Remove mandatory index.php from link handler pattern --- .../features/search/services/handlers/global-search-link.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/features/search/services/handlers/global-search-link.ts b/src/core/features/search/services/handlers/global-search-link.ts index bf767628a..055708e3b 100644 --- a/src/core/features/search/services/handlers/global-search-link.ts +++ b/src/core/features/search/services/handlers/global-search-link.ts @@ -27,7 +27,7 @@ import { makeSingleton } from '@singletons'; export class CoreSearchGlobalSearchLinkHandlerService extends CoreContentLinksHandlerBase { name = 'CoreSearchSearchLinkHandler'; - pattern = /\/search\/index\.php.*/; + pattern = /\/search/; /** * @inheritdoc From 1c9d0962994cdf4133393170da3101975c5c529b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 21 Oct 2024 11:40:26 +0200 Subject: [PATCH 2/2] MOBILE-4616 course: Get course info whatever the user is enrolled or not --- .../pages/course-storage/course-storage.ts | 29 ++----------------- .../module-summary/module-summary.ts | 11 ++----- .../features/course/services/course-helper.ts | 24 +++++++++++++++ 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/addons/storagemanager/pages/course-storage/course-storage.ts b/src/addons/storagemanager/pages/course-storage/course-storage.ts index ebbdf01f5..c64314930 100644 --- a/src/addons/storagemanager/pages/course-storage/course-storage.ts +++ b/src/addons/storagemanager/pages/course-storage/course-storage.ts @@ -25,7 +25,7 @@ import { import { CoreCourseModulePrefetchDelegate, CoreCourseModulePrefetchHandler } from '@features/course/services/module-prefetch-delegate'; -import { CoreCourseAnyCourseData, CoreCourses } from '@features/courses/services/courses'; +import { CoreCourses } from '@features/courses/services/courses'; import { AccordionGroupChangeEventDetail } from '@ionic/angular'; import { CoreLoadings } from '@services/loadings'; import { CoreNavigator } from '@services/navigator'; @@ -612,31 +612,6 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { this.changeDetectorRef.markForCheck(); } - /** - * Get the course object. - * - * @param courseId Course ID. - * @returns Promise resolved with the course object if found. - */ - protected async getCourse(courseId: number): Promise { - try { - // Check if user is enrolled. If enrolled, no guest access. - return await CoreCourses.getUserCourse(courseId, true); - } catch { - // Ignore errors. - } - - try { - // The user is not enrolled in the course. Use getCourses to see if it's an admin/manager and can see the course. - return await CoreCourses.getCourse(courseId); - } catch { - // Ignore errors. - } - - return await CoreCourses.getCourseByField('id', this.courseId); - - } - /** * Prefetch the whole course. * @@ -646,7 +621,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { event.stopPropagation(); event.preventDefault(); - const course = await this.getCourse(this.courseId); + const course = await CoreCourseHelper.getCourseInfo(this.courseId); if (!course) { CoreDomUtils.showErrorModal('core.course.errordownloadingcourse', true); diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts index 910a892de..f04160241 100644 --- a/src/core/features/course/components/module-summary/module-summary.ts +++ b/src/core/features/course/components/module-summary/module-summary.ts @@ -21,7 +21,7 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; -import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; +import { CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { CoreGradesFormattedRow, CoreGradesFormattedTableRow, CoreGradesHelper } from '@features/grades/services/grades-helper'; import { CoreNetwork } from '@services/network'; import { CoreFilepool } from '@services/filepool'; @@ -73,7 +73,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { grades?: CoreGradesFormattedRow[]; blog = false; // If blog is available. isOnline = false; // If the app is online or not. - course?: CoreEnrolledCourseData; + course?: CoreCourseAnyCourseData; modicon = ''; moduleNameTranslated = ''; isTeacher = false; @@ -272,12 +272,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { * Fetch course. */ protected async fetchCourse(): Promise { - try { - this.course = await CoreCourses.getUserCourse(this.courseId, true); - } catch { - // The user is not enrolled in the course. Use getCourses to see if it's an admin/manager and can see the course. - this.course = await CoreCourses.getCourse(this.courseId); - } + this.course = await CoreCourseHelper.getCourseInfo(this.courseId); this.isTeacher = await CoreUtils.ignoreErrors(CoreCourseHelper.guessIsTeacher(this.courseId, this.course), false); } diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 026fb7e88..ff525b53a 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -2052,6 +2052,30 @@ export class CoreCourseHelperProvider { return !!adminOptions[courseId]?.['reports']; } + /** + * Get the course object whatever the user is enrolled or not.. + * + * @param courseId Course ID. + * @returns Promise resolved with the course object if found. + */ + async getCourseInfo(courseId: number): Promise { + try { + // Check if user is enrolled. If enrolled, no guest access. + return await CoreCourses.getUserCourse(courseId, true); + } catch { + // Ignore errors. + } + + try { + // The user is not enrolled in the course. Use getCourses to see if it's an admin/manager and can see the course. + return await CoreCourses.getCourse(courseId); + } catch { + // Ignore errors. + } + + return await CoreCourses.getCourseByField('id', courseId); + } + /** * Get the completion status of a module. *