1 5 package org.exoplatform.portlets.communication.forum; 6 7 import javax.faces.context.FacesContext; 8 import org.exoplatform.services.communication.forum.*; 9 15 public class ForumACL { 16 private String user_ ; 17 18 public ForumACL(String user) { 19 user_ = user ; 20 } 21 22 public String getRemoteUser() { return user_ ; } 23 24 public boolean hasViewForumRole(Forum forum) { 25 String role = forum.getViewForumRole() ; 26 if(role == null || role.length() == 0 || "any".equals(role) || "guest".equals(role)) { 27 return true ; 28 } 29 return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role) ; 30 } 31 32 public boolean hasCreateTopicRole(Forum forum) { 33 String role = forum.getCreateTopicRole() ; 34 if(role == null || role.length() == 0 || "any".equals(role) || "guest".equals(role)) { 35 return true ; 36 } 37 return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role) ; 38 } 39 40 public boolean hasReplyTopicRole(Forum forum) { 41 String role = forum.getReplyTopicRole() ; 42 if(role == null || role.length() == 0 || "any".equals(role) || "guest".equals(role)) { 43 return true ; 44 } 45 return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role) ; 46 } 47 48 public boolean hasModeratorRole(Forum forum) { 49 return forum.isModerator(user_) ; 50 } 51 } 52 | Popular Tags |