Skip to content

Commit

Permalink
SAK-50734 Forums send date to calendar should not be dependent on 'St…
Browse files Browse the repository at this point in the history
…udent' role
  • Loading branch information
ottenhoff committed Dec 7, 2024
1 parent 0ffe68c commit 439ded4
Showing 1 changed file with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2277,15 +2277,8 @@ private void processActionSendToCalendar(MutableEntity forumItem) {
} else { //don't do anything with forumItem or the Calendar if it's not a Forum or a Forum Topic.
return;
}

Collection<Group> allowedGroups = getAllowedGroups(membershipItems);
if (allowedGroups.size() == 0 && !studentsAllowed(membershipItems)) {
sendOpenCloseToCalendar = false; //if no groups or students are allowed to see this, we will treat it as though Send is not checked at all.
if (forumItem instanceof DiscussionTopic) { //clear the forum item's value as well, if this is the case.
((DiscussionTopic) forumItem).setSendOpenCloseToCalendar(false);
} else if (forumItem instanceof DiscussionForum) {
((DiscussionForum) forumItem).setSendOpenCloseToCalendar(false);
}
}
try { //now actually start processing the data for Calendar.
Calendar targetCalendar = this.calendarService.getCalendar(calendarService.calendarReference(getContextSiteId().replace("/site/",""), siteService.MAIN_CONTAINER));
if(targetCalendar == null){
Expand Down Expand Up @@ -2443,13 +2436,6 @@ private Collection<Group> getAllowedGroups(Set<DBMembershipItem> membershipItems
return output;
}

private Boolean studentsAllowed (Set<DBMembershipItem> membershipItems){ //find out if users in the Student role are allowed to use a Forum Item in any way.
if (membershipItems != null) {
return membershipItems.stream().filter(itemNow -> itemNow.getName().equals("Student") && !itemNow.getPermissionLevelName().equals("None")).findFirst().isPresent();
}
return false;
}

/**
* @return
*/
Expand Down

0 comments on commit 439ded4

Please sign in to comment.