diff --git a/scripts/langindex.json b/scripts/langindex.json index c9486501c..92ad0f979 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -75,7 +75,6 @@ "addon.calendar.eventstarttime": "calendar", "addon.calendar.gotoactivity": "calendar", "addon.calendar.noevents": "local_moodlemobileapp", - "addon.calendar.notifications": "local_moodlemobileapp", "addon.calendar.reminders": "local_moodlemobileapp", "addon.calendar.setnewreminder": "local_moodlemobileapp", "addon.calendar.typecategory": "calendar", diff --git a/src/addon/badges/providers/mybadges-link-handler.ts b/src/addon/badges/providers/mybadges-link-handler.ts index 8c58e384d..8a36cbbc0 100644 --- a/src/addon/badges/providers/mybadges-link-handler.ts +++ b/src/addon/badges/providers/mybadges-link-handler.ts @@ -19,7 +19,7 @@ import { CoreLoginHelperProvider } from '@core/login/providers/helper'; import { AddonBadgesProvider } from './badges'; /** - * Handler to treat links to user participants page. + * Handler to treat links to user badges page. */ @Injectable() export class AddonBadgesMyBadgesLinkHandler extends CoreContentLinksHandlerBase { diff --git a/src/addon/blog/blog.module.ts b/src/addon/blog/blog.module.ts index 275a16873..f31372745 100644 --- a/src/addon/blog/blog.module.ts +++ b/src/addon/blog/blog.module.ts @@ -16,11 +16,13 @@ import { NgModule } from '@angular/core'; import { CoreMainMenuDelegate } from '@core/mainmenu/providers/delegate'; import { CoreUserDelegate } from '@core/user/providers/user-delegate'; import { CoreCourseOptionsDelegate } from '@core/course/providers/options-delegate'; +import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate'; import { AddonBlogProvider } from './providers/blog'; import { AddonBlogMainMenuHandler } from './providers/mainmenu-handler'; import { AddonBlogUserHandler } from './providers/user-handler'; import { AddonBlogCourseOptionHandler } from './providers/course-option-handler'; import { AddonBlogComponentsModule } from './components/components.module'; +import { AddonBlogIndexLinkHandler } from './providers/index-link-handler'; @NgModule({ declarations: [ @@ -32,15 +34,18 @@ import { AddonBlogComponentsModule } from './components/components.module'; AddonBlogProvider, AddonBlogMainMenuHandler, AddonBlogUserHandler, - AddonBlogCourseOptionHandler + AddonBlogCourseOptionHandler, + AddonBlogIndexLinkHandler ] }) export class AddonBlogModule { constructor(mainMenuDelegate: CoreMainMenuDelegate, menuHandler: AddonBlogMainMenuHandler, userHandler: AddonBlogUserHandler, userDelegate: CoreUserDelegate, - courseOptionHandler: AddonBlogCourseOptionHandler, courseOptionsDelegate: CoreCourseOptionsDelegate) { + courseOptionHandler: AddonBlogCourseOptionHandler, courseOptionsDelegate: CoreCourseOptionsDelegate, + linkHandler: AddonBlogIndexLinkHandler, contentLinksDelegate: CoreContentLinksDelegate) { mainMenuDelegate.registerHandler(menuHandler); userDelegate.registerHandler(userHandler); courseOptionsDelegate.registerHandler(courseOptionHandler); + contentLinksDelegate.registerHandler(linkHandler); } } diff --git a/src/addon/blog/components/entries/entries.ts b/src/addon/blog/components/entries/entries.ts index f946264a8..282c6ef87 100644 --- a/src/addon/blog/components/entries/entries.ts +++ b/src/addon/blog/components/entries/entries.ts @@ -30,6 +30,9 @@ export class AddonBlogEntriesComponent implements OnInit { @Input() userId?: number; @Input() courseId?: number; @Input() cmId?: number; + @Input() entryId?: number; + @Input() groupId?: number; + @Input() tagId?: number; protected filter = {}; protected pageLoaded = 0; @@ -66,6 +69,18 @@ export class AddonBlogEntriesComponent implements OnInit { this.filter['cmid'] = this.cmId; } + if (this.entryId) { + this.filter['entryid'] = this.entryId; + } + + if (this.groupId) { + this.filter['groupid'] = this.groupId; + } + + if (this.tagId) { + this.filter['tagid'] = this.tagId; + } + this.fetchEntries().then(() => { this.blogProvider.logView(this.filter).catch(() => { // Ignore errors. diff --git a/src/addon/blog/pages/entries/entries.html b/src/addon/blog/pages/entries/entries.html index ff5f1b240..e5a12aba8 100644 --- a/src/addon/blog/pages/entries/entries.html +++ b/src/addon/blog/pages/entries/entries.html @@ -4,4 +4,4 @@ - + diff --git a/src/addon/blog/pages/entries/entries.ts b/src/addon/blog/pages/entries/entries.ts index 1a268268f..220de15df 100644 --- a/src/addon/blog/pages/entries/entries.ts +++ b/src/addon/blog/pages/entries/entries.ts @@ -27,14 +27,20 @@ export class AddonBlogEntriesPage { userId: number; courseId: number; cmId: number; + entryId: number; + groupId: number; + tagId: number; title: string; constructor(params: NavParams) { this.userId = params.get('userId'); this.courseId = params.get('courseId'); this.cmId = params.get('cmId'); + this.entryId = params.get('entryId'); + this.groupId = params.get('groupId'); + this.tagId = params.get('tagId'); - if (!this.userId && !this.courseId && !this.cmId) { + if (!this.userId && !this.courseId && !this.cmId && !this.entryId && !this.groupId && !this.tagId) { this.title = 'addon.blog.siteblogheading'; } else { this.title = 'addon.blog.blogentries'; diff --git a/src/addon/blog/providers/index-link-handler.ts b/src/addon/blog/providers/index-link-handler.ts new file mode 100644 index 000000000..176aec76e --- /dev/null +++ b/src/addon/blog/providers/index-link-handler.ts @@ -0,0 +1,76 @@ +// (C) Copyright 2015 Martin Dougiamas +// +// 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 { Injectable } from '@angular/core'; +import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler'; +import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate'; +import { CoreLoginHelperProvider } from '@core/login/providers/helper'; +import { AddonBlogProvider } from './blog'; + +/** + * Handler to treat links to blog page. + */ +@Injectable() +export class AddonBlogIndexLinkHandler extends CoreContentLinksHandlerBase { + name = 'AddonBlogIndexLinkHandler'; + featureName = 'CoreUserDelegate_AddonBlog'; + pattern = /\/blog\/index\.php/; + + constructor(private blogProvider: AddonBlogProvider, private loginHelper: CoreLoginHelperProvider) { + super(); + } + + /** + * Get the list of actions for a link (url). + * + * @param {string[]} siteIds List of sites the URL belongs to. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {CoreContentLinksAction[]|Promise} List of (or promise resolved with list of) actions. + */ + getActions(siteIds: string[], url: string, params: any, courseId?: number): + CoreContentLinksAction[] | Promise { + const pageParams: any = {}; + + params.userid ? pageParams['userId'] = parseInt(params.userid, 10) : null; + params.modid ? pageParams['cmId'] = parseInt(params.modid, 10) : null; + params.courseid ? pageParams['courseId'] = parseInt(params.courseid, 10) : null; + params.entryid ? pageParams['entryId'] = parseInt(params.entryid, 10) : null; + params.groupid ? pageParams['groupId'] = parseInt(params.groupid, 10) : null; + params.tagid ? pageParams['tagId'] = parseInt(params.tagid, 10) : null; + + return [{ + action: (siteId, navCtrl?): void => { + // Always use redirect to make it the new history root (to avoid "loops" in history). + this.loginHelper.redirect('AddonBlogEntriesPage', pageParams, siteId); + } + }]; + } + + /** + * Check if the handler is enabled for a certain site (site + user) and a URL. + * If not defined, defaults to true. + * + * @param {string} siteId The site ID. + * @param {string} url The URL to treat. + * @param {any} params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1} + * @param {number} [courseId] Course ID related to the URL. Optional but recommended. + * @return {boolean|Promise} Whether the handler is enabled for the URL and site. + */ + isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise { + + return this.blogProvider.isPluginEnabled(siteId); + } +}