/** * @return List of DiscussionForumBean */ public List getForums() { LOG.debug("getForums()"); if (forums != null && forums.size() > 0) { return forums; } // query the database for all of the forums that are associated with the current site List tempForums = forumManager.getForumsForMainPage(); if (tempForums == null || tempForums.size() < 1) { return null; } // establish some values that we will check multiple times to shave a few processing cycles boolean readFullDescription = "true".equalsIgnoreCase(ServerConfigurationService.getString("mc.defaultLongDescription")); // run through the topics once to get their parent forums, create the decorated topics that will be used later, and // possibly set the message count SortedSet tempSortedForums = new TreeSet(new ForumBySortIndexAscAndCreatedDateDesc()); Map topicBeans = new HashMap(); Set topicIdsForCounts = new HashSet(); for (DiscussionForum forum: tempForums) { if (!forum.getDraft() || SecurityService.isSuperUser() || isInstructor() || forum.getCreatedBy().equals(getUserId())) { // this is the start of the big forum if tempSortedForums.add(forum); for (Iterator itor = forum.getTopicsSet().iterator(); itor.hasNext(); ) { DiscussionTopic currTopic = (DiscussionTopic)itor.next(); if (currTopic.getDraft().equals(Boolean.FALSE) || isInstructor() || SecurityService.isSuperUser() || currTopic.getCreatedBy().equals(getUserId())) { // this is the start of the big topic if DiscussionTopicBean decoTopic = new DiscussionTopicBean(currTopic, (DiscussionForum)currTopic.getOpenForum(), uiPermissionsManager, forumManager); if (readFullDescription) decoTopic.setReadFullDesciption(true); // set the message count for moderated topics, otherwise it will be set later if (currTopic.getModerated() && !uiPermissionsManager.isModeratePostings(currTopic, (DiscussionForum)currTopic.getOpenForum())) { decoTopic.setTotalNoMessages(forumManager.getTotalViewableMessagesWhenMod(currTopic)); decoTopic.setUnreadNoMessages(forumManager.getNumUnreadViewableMessagesWhenMod(currTopic)); } else { topicIdsForCounts.add(currTopic.getId()); } topicBeans.put(currTopic.getId(), decoTopic); } // end the big topic if } } // end the big forum if } // get the total message count of non-moderated topics and add them to the discussion topic bean and // initialize the unread number of messages to all of them. List topicMessageCounts = forumManager.getMessageCountsForMainPage(topicIdsForCounts); for (Object[] counts: topicMessageCounts) { DiscussionTopicBean decoTopic = topicBeans.get(counts[0]); decoTopic.setTotalNoMessages((Integer)counts[1]); decoTopic.setUnreadNoMessages((Integer)counts[1]); } // get the total read message count for the current user of non-moderated and add them to the discussion // topic bean as the number of unread messages. I could've combined this with the previous query but // stupid Hibernate (3.x) won't let us properly outer join mapped entitys that do not have a direct // association. BLURG! Any topic not in the returned list means the user hasn't read any of the messages // in that topic which is why I set the default unread message count to all the messages in the previous // loop. topicMessageCounts = forumManager.getReadMessageCountsForMainPage(topicIdsForCounts); for (Object[] counts: topicMessageCounts) { DiscussionTopicBean decoTopic = topicBeans.get(counts[0]); decoTopic.setUnreadNoMessages(decoTopic.getTotalNoMessages() - (Integer)counts[1]); } // get the assignments for use later try { assignments = new ArrayList(); assignments.add(new SelectItem(DEFAULT_GB_ITEM, getResourceBundleString(SELECT_ASSIGN))); GradebookService gradebookService = (org.sakaiproject.service.gradebook.shared.GradebookService) ComponentManager.get("org.sakaiproject.service.gradebook.GradebookService"); if(getGradebookExist()) { List gradeAssignmentsBeforeFilter = gradebookService.getAssignments(ToolManager.getCurrentPlacement().getContext()); for(int i=0; i(); int sortIndex = 1; for (DiscussionForum forum: tempSortedForums) { // manually set the sort index now that the list is sorted forum.setSortIndex(new Integer(sortIndex)); sortIndex++; DiscussionForumBean decoForum = new DiscussionForumBean(forum, uiPermissionsManager, forumManager); if (readFullDescription) decoForum.setReadFullDesciption(true); if (forum.getTopics() != null) { for (Iterator itor = forum.getTopics().iterator(); itor.hasNext(); ) { DiscussionTopic topic = (DiscussionTopic) itor.next(); DiscussionTopicBean decoTopic = topicBeans.get(topic.getId()); if (decoTopic != null) decoForum.addTopic(decoTopic); } } decoForum.setGradeAssign(DEFAULT_GB_ITEM); for(int i=0; i