Skip to content

Commit

Permalink
Merge pull request sakaiproject#33 from pushyamig/master
Browse files Browse the repository at this point in the history
SAK-28074 Changing the Forum feed permission logic
  • Loading branch information
bethkirschner committed Jan 13, 2015
2 parents a35bd87 + f35464c commit fb58159
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.sakaiproject.api.app.messageforums.ui.DiscussionForumManager;
import org.sakaiproject.api.app.messageforums.ui.UIPermissionsManager;
import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entitybroker.EntityView;
import org.sakaiproject.entitybroker.entityprovider.annotations.EntityCustomAction;
import org.sakaiproject.entitybroker.entityprovider.capabilities.*;
Expand Down Expand Up @@ -159,7 +160,7 @@ private List<?> getAllForaForSite(String siteId,String userId) {

for(DiscussionForum fatForum : fatFora) {

if( ! checkAccess(fatForum,userId)) {
if( ! checkAccess(fatForum,userId,siteId)) {
LOG.warn("Access denied for user id '" + userId + "' to forum '" + fatForum.getId()
+ "'. This forum will not be returned.");
continue;
Expand Down Expand Up @@ -205,7 +206,7 @@ private Object getForum(Long forumId, String siteId, String userId) {

DiscussionForum fatForum = forumManager.getForumByIdWithTopicsAttachmentsAndMessages(forumId);

if(checkAccess(fatForum,userId)) {
if(checkAccess(fatForum,userId,siteId)) {

SparseForum sparseForum = new SparseForum(fatForum,developerHelperService);

Expand Down Expand Up @@ -356,12 +357,12 @@ private Object getMessage(Long messageId,String siteId,String userId) {

}

private boolean checkAccess(BaseForum baseForum, String userId) {
private boolean checkAccess(BaseForum baseForum, String userId, String siteId) {

if(baseForum instanceof OpenForum) {

// If the supplied user is the super user, return true.
if(securityService.isSuperUser(userId)) {
// If the supplied user is the super user or an instructor, return true.
if(securityService.isSuperUser(userId) || forumManager.isInstructor(userId, Entity.SEPARATOR + SiteService.SITE_SUBTYPE + Entity.SEPARATOR + siteId)) {
return true;
}

Expand Down

0 comments on commit fb58159

Please sign in to comment.