MOBILE-3019 forum: Disallow posting if cut-off date is reached
This commit is contained in:
		
							parent
							
								
									12ceba7eac
								
							
						
					
					
						commit
						2d16b37153
					
				| @ -97,7 +97,7 @@ | ||||
|             <core-infinite-loading [enabled]="canLoadMore" (action)="fetchMoreDiscussions($event)" [error]="loadMoreError"></core-infinite-loading> | ||||
|         </core-loading> | ||||
| 
 | ||||
|         <ion-fab core-fab bottom end *ngIf="forum && forum.cancreatediscussions"> | ||||
|         <ion-fab core-fab bottom end *ngIf="forum && canAddDiscussion"> | ||||
|             <button ion-fab (click)="openNewDiscussion()" [attr.aria-label]="addDiscussionText"> | ||||
|                 <ion-icon name="add"></ion-icon> | ||||
|             </button> | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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.
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user