コード例 #1
0
 /**
  * @see org.olat.search.service.indexer.Indexer#checkAccess(org.olat.core.id.context.ContextEntry,
  *     org.olat.core.id.context.BusinessControl, org.olat.core.id.Identity,
  *     org.olat.core.id.Roles)
  */
 @Override
 public boolean checkAccess(
     final ContextEntry contextEntry,
     final BusinessControl businessControl,
     final Identity identity,
     final Roles roles) {
   // TODO:chg: check with collabTools if forum is enabled
   final ContextEntry ce = businessControl.popLauncherContextEntry();
   final Long resourceableId = ce.getOLATResourceable().getResourceableId();
   final Message message = ForumManager.getInstance().loadMessage(resourceableId);
   Message threadtop = message.getThreadtop();
   if (threadtop == null) {
     threadtop = message;
   }
   final boolean isMessageHidden = Status.getStatus(threadtop.getStatusCode()).isHidden();
   // assumes that if is owner then is moderator so it is allowed to see the hidden forum threads
   // TODO: (LD) fix this!!!
   // here it is checked if the identity is owner of the forum tool but it has no way to find out
   // whether is owner of the group that owns the forum tool
   final boolean isOwner =
       BaseSecurityManager.getInstance()
           .isIdentityPermittedOnResourceable(
               identity, Constants.PERMISSION_ACCESS, contextEntry.getOLATResourceable());
   if (isMessageHidden && !isOwner) {
     return false;
   }
   return true;
 }
コード例 #2
0
  /**
   * If the forumCallback is null no filtering is executed, else if a thread is hidden and the user
   * doesn't have moderator rights the hidden thread is not included into the archive.
   *
   * @param forumId
   * @param metaInfo
   * @return all top message nodes together with their children in a list
   */
  private List convertToThreadTrees(final long forumId, final ForumCallback forumCallback) {
    List messages;
    final List topNodeList = new ArrayList();
    final ForumManager fm = ForumManager.getInstance();
    final Long l = new Long(forumId);
    final Forum f = fm.loadForum(l);
    messages = fm.getMessagesByForum(f);

    for (final Iterator iterTop = messages.iterator(); iterTop.hasNext(); ) {
      final Message msg = (Message) iterTop.next();
      if (msg.getParent() == null) {
        iterTop.remove();
        final MessageNode topNode = new MessageNode(msg);
        if (topNode.isHidden()
            && (forumCallback == null
                || (forumCallback != null && forumCallback.mayEditMessageAsModerator()))) {
          addChildren(messages, topNode);
          topNodeList.add(topNode);
        } else if (!topNode.isHidden()) {
          addChildren(messages, topNode);
          topNodeList.add(topNode);
        }
      }
    }
    return getMessagesSorted(topNodeList);
  }
コード例 #3
0
 private void addChildren(final List messages, final MessageNode mn) {
   for (final Iterator iterMsg = messages.iterator(); iterMsg.hasNext(); ) {
     final Message msg = (Message) iterMsg.next();
     if ((msg.getParent() != null) && (msg.getParent().getKey() == mn.getKey())) {
       final MessageNode childNode = new MessageNode(msg);
       mn.addChild(childNode);
       // FIXME:as:c next line is not necessary
       childNode.setParent(mn);
       addChildren(messages, childNode);
     }
   }
 }
コード例 #4
0
 /**
  * @param messageId
  * @param metaInfo
  * @return the top message node with all its children
  */
 private MessageNode convertToThreadTree(final long topMessageId) {
   List messages;
   MessageNode topNode = null;
   final ForumManager fm = ForumManager.getInstance();
   final Long l = new Long(topMessageId);
   messages = fm.getThread(l);
   for (final Iterator iterTop = messages.iterator(); iterTop.hasNext(); ) {
     final Message msg = (Message) iterTop.next();
     if (msg.getParent() == null) {
       iterTop.remove();
       topNode = new MessageNode(msg);
       addChildren(messages, topNode);
     }
   }
   return topNode;
 }