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-infinite-loading [enabled]="canLoadMore" (action)="fetchMoreDiscussions($event)" [error]="loadMoreError"></core-infinite-loading> | ||||||
|         </core-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"> |             <button ion-fab (click)="openNewDiscussion()" [attr.aria-label]="addDiscussionText"> | ||||||
|                 <ion-icon name="add"></ion-icon> |                 <ion-icon name="add"></ion-icon> | ||||||
|             </button> |             </button> | ||||||
|  | |||||||
| @ -48,6 +48,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|     discussions = []; |     discussions = []; | ||||||
|     offlineDiscussions = []; |     offlineDiscussions = []; | ||||||
|     selectedDiscussion = 0; // Disucssion ID or negative timecreated if it's an offline discussion.
 |     selectedDiscussion = 0; // Disucssion ID or negative timecreated if it's an offline discussion.
 | ||||||
|  |     canAddDiscussion = false; | ||||||
|     addDiscussionText = this.translate.instant('addon.mod_forum.addanewdiscussion'); |     addDiscussionText = this.translate.instant('addon.mod_forum.addanewdiscussion'); | ||||||
|     availabilityMessage: string; |     availabilityMessage: string; | ||||||
| 
 | 
 | ||||||
| @ -199,10 +200,18 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|                 }); |                 }); | ||||||
|             } |             } | ||||||
|         }).then(() => { |         }).then(() => { | ||||||
|  |             return Promise.all([ | ||||||
|                 // Check if the activity uses groups.
 |                 // Check if the activity uses groups.
 | ||||||
|             return this.groupsProvider.getActivityGroupMode(this.forum.cmid).then((mode) => { |                 this.groupsProvider.getActivityGroupMode(this.forum.cmid).then((mode) => { | ||||||
|                     this.usesGroups = (mode === CoreGroupsProvider.SEPARATEGROUPS || mode === CoreGroupsProvider.VISIBLEGROUPS); |                     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(() => { |         }).then(() => { | ||||||
|             return Promise.all([ |             return Promise.all([ | ||||||
|                 this.fetchOfflineDiscussion(), |                 this.fetchOfflineDiscussion(), | ||||||
| @ -370,6 +379,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom | |||||||
|         if (this.forum) { |         if (this.forum) { | ||||||
|             promises.push(this.forumProvider.invalidateDiscussionsList(this.forum.id)); |             promises.push(this.forumProvider.invalidateDiscussionsList(this.forum.id)); | ||||||
|             promises.push(this.groupsProvider.invalidateActivityGroupMode(this.forum.cmid)); |             promises.push(this.groupsProvider.invalidateActivityGroupMode(this.forum.cmid)); | ||||||
|  |             promises.push(this.forumProvider.invalidateAccessInformation(this.forum.id)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return Promise.all(promises); |         return Promise.all(promises); | ||||||
|  | |||||||
| @ -318,6 +318,14 @@ export class AddonModForumDiscussionPage implements OnDestroy { | |||||||
| 
 | 
 | ||||||
|                 promises.push(this.forumProvider.getAccessInformation(this.forum.id).then((accessInfo) => { |                 promises.push(this.forumProvider.getAccessInformation(this.forum.id).then((accessInfo) => { | ||||||
|                     this.accessInfo = 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.
 |                 // Fetch the discussion if not passed as parameter.
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user