diff --git a/src/addon/mod/forum/components/index/addon-mod-forum-index.html b/src/addon/mod/forum/components/index/addon-mod-forum-index.html index 497f32f02..f0f1fa603 100644 --- a/src/addon/mod/forum/components/index/addon-mod-forum-index.html +++ b/src/addon/mod/forum/components/index/addon-mod-forum-index.html @@ -97,7 +97,7 @@ - + diff --git a/src/addon/mod/forum/components/index/index.ts b/src/addon/mod/forum/components/index/index.ts index 60ee32288..762df73f4 100644 --- a/src/addon/mod/forum/components/index/index.ts +++ b/src/addon/mod/forum/components/index/index.ts @@ -48,6 +48,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom discussions = []; offlineDiscussions = []; selectedDiscussion = 0; // Disucssion ID or negative timecreated if it's an offline discussion. + canAddDiscussion = false; addDiscussionText = this.translate.instant('addon.mod_forum.addanewdiscussion'); availabilityMessage: string; @@ -199,10 +200,18 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom }); } }).then(() => { - // Check if the activity uses groups. - return this.groupsProvider.getActivityGroupMode(this.forum.cmid).then((mode) => { - this.usesGroups = (mode === CoreGroupsProvider.SEPARATEGROUPS || mode === CoreGroupsProvider.VISIBLEGROUPS); - }); + return Promise.all([ + // Check if the activity uses groups. + this.groupsProvider.getActivityGroupMode(this.forum.cmid).then((mode) => { + this.usesGroups = (mode === CoreGroupsProvider.SEPARATEGROUPS || mode === CoreGroupsProvider.VISIBLEGROUPS); + }), + this.forumProvider.getAccessInformation(this.forum.id).then((accessInfo) => { + // Disallow adding discussions if cut-off date is reached and the user has not the capability to override it. + // Just in case the forum was fetched from WS when the cut-off date was not reached but it is now. + const cutoffDateReached = this.forumHelper.isCutoffDateReached(this.forum) && !accessInfo.cancanoverridecutoff; + this.canAddDiscussion = this.forum.cancreatediscussions && !cutoffDateReached; + }), + ]); }).then(() => { return Promise.all([ this.fetchOfflineDiscussion(), @@ -370,6 +379,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom if (this.forum) { promises.push(this.forumProvider.invalidateDiscussionsList(this.forum.id)); promises.push(this.groupsProvider.invalidateActivityGroupMode(this.forum.cmid)); + promises.push(this.forumProvider.invalidateAccessInformation(this.forum.id)); } return Promise.all(promises); diff --git a/src/addon/mod/forum/pages/discussion/discussion.ts b/src/addon/mod/forum/pages/discussion/discussion.ts index 9d0a44fee..3aee91f1b 100644 --- a/src/addon/mod/forum/pages/discussion/discussion.ts +++ b/src/addon/mod/forum/pages/discussion/discussion.ts @@ -318,6 +318,14 @@ export class AddonModForumDiscussionPage implements OnDestroy { promises.push(this.forumProvider.getAccessInformation(this.forum.id).then((accessInfo) => { this.accessInfo = accessInfo; + + // Disallow replying if cut-off date is reached and the user has not the capability to override it. + // Just in case the posts were fetched from WS when the cut-off date was not reached but it is now. + if (this.forumHelper.isCutoffDateReached(forum) && !accessInfo.cancanoverridecutoff) { + posts.forEach((post) => { + post.canreply = false; + }); + } })); // Fetch the discussion if not passed as parameter.