Index: messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/entity/TopicEntityProviderImpl.java =================================================================== --- messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/entity/TopicEntityProviderImpl.java (revision 310754) +++ messageforums-component-impl/src/java/org/sakaiproject/component/app/messageforums/entity/TopicEntityProviderImpl.java (working copy) @@ -337,7 +337,15 @@ for (DiscussionForum forum : forums) { if(forum.getDraft().equals(Boolean.FALSE)){ - DecoratedForumInfo dForum = new DecoratedForumInfo(forum.getId(), forum.getTitle()); + Long forumOpenDate = null; + Long forumCloseDate = null; + if (forum.getAvailabilityRestricted()) { + forumOpenDate = forum.getOpenDate() != null ? forum.getOpenDate().getTime()/1000 : null; + forumCloseDate = forum.getCloseDate() != null ? forum.getCloseDate().getTime()/1000 : null; + } + + DecoratedForumInfo dForum = new DecoratedForumInfo(forum.getId(), forum.getTitle(), forum.getLocked(), + forum.getPostFirst(), forum.getAvailabilityRestricted(), forumOpenDate, forumCloseDate, forum.getDefaultAssignName()); List topics = forum.getTopics(); int viewableTopics = 0; @@ -363,8 +371,16 @@ unreadMessages = getMessageManager().findUnreadViewableMessageCountByTopicIdByUserId(topic.getId(), userId); } totalMessages = getMessageManager().findViewableMessageCountByTopicIdByUserId(topic.getId(), userId); - - dForum.addTopic(new DecoratedTopicInfo(topic.getId(), topic.getTitle(), unreadMessages, totalMessages, "")); + + Long topicOpenDate = null; + Long topicCloseDate = null; + if (topic.getAvailabilityRestricted()) { + topicOpenDate = topic.getOpenDate() != null ? topic.getOpenDate().getTime()/1000 : null; + topicCloseDate = topic.getCloseDate() != null ? topic.getCloseDate().getTime()/1000 : null; + } + dForum.addTopic(new DecoratedTopicInfo(topic.getId(), topic.getTitle(), unreadMessages, + totalMessages, "", topic.getLocked(), topic.getPostFirst(), topic.getAvailabilityRestricted(), + topicOpenDate, topicCloseDate, topic.getDefaultAssignName())); viewableTopics++; } } Index: messageforums-api/src/java/org/sakaiproject/api/app/messageforums/entity/DecoratedForumInfo.java =================================================================== --- messageforums-api/src/java/org/sakaiproject/api/app/messageforums/entity/DecoratedForumInfo.java (revision 310754) +++ messageforums-api/src/java/org/sakaiproject/api/app/messageforums/entity/DecoratedForumInfo.java (working copy) @@ -8,7 +8,35 @@ private Long forumId; private String forumTitle; private List topics = new ArrayList(); + private Boolean isLocked; + private Boolean isPostFirst; + private Boolean isAvailabilityRestricted; + /** + * An epoch date in seconds. NOT milliseconds. + */ + private Long openDate; + /** + * An epoch date in seconds. NOT milliseconds. + */ + private Long closeDate; + private String gradebookItemName; + + public DecoratedForumInfo(Long forumId, String forumTitle){ + this.forumId = forumId; + this.forumTitle = forumTitle; + } + public DecoratedForumInfo(Long forumId, String forumTitle, Boolean isLocked, + Boolean isPostFirst, Boolean isAvailabilityRestricted, Long openDate, + Long closeDate, String gradebookItemName) { + this(forumId, forumTitle); + this.isLocked = isLocked; + this.isPostFirst = isPostFirst; + this.isAvailabilityRestricted = isAvailabilityRestricted; + this.openDate = openDate; + this.closeDate = closeDate; + this.gradebookItemName = gradebookItemName; + } public Long getForumId() { return forumId; @@ -40,12 +68,57 @@ } - public DecoratedForumInfo(Long forumId, String forumTitle){ - this.forumId = forumId; - this.forumTitle = forumTitle; - } + public void addTopic(DecoratedTopicInfo topic){ this.topics.add(topic); } + + public Boolean getIsLocked() { + return isLocked; + } + + public void setIsLocked(Boolean isLocked) { + this.isLocked = isLocked; + } + + public Boolean getIsPostFirst() { + return isPostFirst; + } + + public void setIsPostFirst(Boolean isPostFirst) { + this.isPostFirst = isPostFirst; + } + + public Boolean getIsAvailabilityRestricted() { + return isAvailabilityRestricted; + } + + public void setIsAvailabilityRestricted(Boolean isAvailabilityRestricted) { + this.isAvailabilityRestricted = isAvailabilityRestricted; + } + + public Long getOpenDate() { + return openDate; + } + + public void setOpenDate(Long openDate) { + this.openDate = openDate; + } + + public Long getCloseDate() { + return closeDate; + } + + public void setCloseDate(Long closeDate) { + this.closeDate = closeDate; + } + + public String getGradebookItemName() { + return gradebookItemName; + } + + public void setGradebookItemName(String gradebookItemName) { + this.gradebookItemName = gradebookItemName; + } } Index: messageforums-api/src/java/org/sakaiproject/api/app/messageforums/entity/DecoratedTopicInfo.java =================================================================== --- messageforums-api/src/java/org/sakaiproject/api/app/messageforums/entity/DecoratedTopicInfo.java (revision 310754) +++ messageforums-api/src/java/org/sakaiproject/api/app/messageforums/entity/DecoratedTopicInfo.java (working copy) @@ -6,14 +6,19 @@ private int unreadMessagesCount = 0; private int messagesCount = 0; private String typeUuid; - - public String getTypeUuid() { - return typeUuid; - } + private Boolean isLocked; + private Boolean isPostFirst; + private Boolean isAvailabilityRestricted; + /** + * An epoch date in seconds. NOT milliseconds. + */ + private Long openDate; + /** + * An epoch date in seconds. NOT milliseconds. + */ + private Long closeDate; + private String gradebookItemName; - public void setTypeUuid(String typeUuid) { - this.typeUuid = typeUuid; - } public DecoratedTopicInfo(Long topicId, String topicTitle, int unreadMessagesCount, int messagesCount, String typeUuid){ this.topicId = topicId; @@ -23,6 +28,27 @@ this.typeUuid = typeUuid; } + public DecoratedTopicInfo(Long topicId, String topicTitle, int unreadMessagesCount, + int messagesCount, String typeUuid, Boolean isLocked, Boolean isPostFirst, + Boolean isAvailabilityRestricted, Long openDate, Long closeDate, String gradebookItemName) { + + this(topicId, topicTitle, unreadMessagesCount, messagesCount, typeUuid); + this.isLocked = isLocked; + this.isPostFirst = isPostFirst; + this.isAvailabilityRestricted = isAvailabilityRestricted; + this.openDate = openDate; + this.closeDate = closeDate; + this.gradebookItemName = gradebookItemName; + } + + public String getTypeUuid() { + return typeUuid; + } + + public void setTypeUuid(String typeUuid) { + this.typeUuid = typeUuid; + } + public Long getTopicId() { return topicId; } @@ -50,5 +76,53 @@ public void setMessagesCount(int messagesCount) { this.messagesCount = messagesCount; } + + public Boolean getIsLocked() { + return isLocked; + } + public void setIsLocked(Boolean isLocked) { + this.isLocked = isLocked; + } + + public Boolean getIsPostFirst() { + return isPostFirst; + } + + public void setIsPostFirst(Boolean isPostFirst) { + this.isPostFirst = isPostFirst; + } + + public Boolean getIsAvailabilityRestricted() { + return isAvailabilityRestricted; + } + + public void setIsAvailabilityRestricted(Boolean isAvailabilityRestricted) { + this.isAvailabilityRestricted = isAvailabilityRestricted; + } + + public Long getOpenDate() { + return openDate; + } + + public void setOpenDate(Long openDate) { + this.openDate = openDate; + } + + public Long getCloseDate() { + return closeDate; + } + + public void setCloseDate(Long closeDate) { + this.closeDate = closeDate; + } + + public String getGradebookItemName() { + return gradebookItemName; + } + + public void setGradebookItemName(String gradebookItemName) { + this.gradebookItemName = gradebookItemName; + } + } Index: messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/ForumsEntityProviderImpl.java =================================================================== --- messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/ForumsEntityProviderImpl.java (revision 310754) +++ messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/ForumsEntityProviderImpl.java (working copy) @@ -282,9 +282,9 @@ } // This call gets the attachments for the messages but not the topic. Unexpected, yes. Cool, not. - Topic fatTopic = forumManager.getTopicByIdWithMessagesAndAttachments(topicId); + DiscussionTopic fatTopic = (DiscussionTopic)forumManager.getTopicByIdWithMessagesAndAttachments(topicId); - if(!uiPermissionsManager.isRead(topicId,((DiscussionTopic)fatTopic).getDraft(),false,userId,forumManager.getContextForTopicById(topicId))) { + if(!uiPermissionsManager.isRead(topicId,fatTopic.getDraft(),false,userId,forumManager.getContextForTopicById(topicId))) { LOG.error("'" + userId + "' is not authorised to read topic '" + topicId + "'."); throw new EntityException("You are not authorised to read this topic.","",HttpServletResponse.SC_UNAUTHORIZED); } Index: messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/sparsepojos/SparsestTopic.java =================================================================== --- messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/sparsepojos/SparsestTopic.java (revision 310754) +++ messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/sparsepojos/SparsestTopic.java (working copy) @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.Setter; +import org.sakaiproject.api.app.messageforums.DiscussionTopic; import org.sakaiproject.api.app.messageforums.Topic; public class SparsestTopic { @@ -37,6 +38,30 @@ @Getter @Setter private Integer readMessages = 0; + @Getter + private Boolean isLocked; + + @Getter + private Boolean isPostFirst; + + @Getter + private String assocGradebookItemName; + + @Getter + private Boolean isAvailabilityRestricted; + + /** + * An epoch date in seconds. NOT milliseconds. + */ + @Getter + private Long openDate; + + /** + * An epoch date in seconds. NOT milliseconds. + */ + @Getter + private Long closeDate; + @Getter @Setter private List attachments = new ArrayList(); @@ -49,5 +74,21 @@ this.modifiedDate = fatTopic.getModified().getTime()/1000; this.modifier = fatTopic.getModifiedBy(); this.isAutoMarkThreadsRead = fatTopic.getAutoMarkThreadsRead(); + this.isAvailabilityRestricted = fatTopic.getAvailabilityRestricted(); + + if (this.isAvailabilityRestricted != null && this.isAvailabilityRestricted) { + this.openDate = fatTopic.getOpenDate() != null ? fatTopic.getOpenDate().getTime()/1000 : null; + this.closeDate = fatTopic.getCloseDate() != null ? fatTopic.getCloseDate().getTime()/1000 : null; + } + + this.assocGradebookItemName = fatTopic.getDefaultAssignName(); + + // The Topic object is used by both the Forums and Messages tools, and there are + // properties specific to the Forums tool that are only available on the child + // DiscussionTopic object + if (fatTopic instanceof DiscussionTopic) { + this.isLocked = ((DiscussionTopic)fatTopic).getLocked(); + this.isPostFirst = ((DiscussionTopic)fatTopic).getPostFirst(); + } } } Index: messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/sparsepojos/SparsestForum.java =================================================================== --- messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/sparsepojos/SparsestForum.java (revision 310754) +++ messageforums-app/src/java/org/sakaiproject/tool/messageforums/entityproviders/sparsepojos/SparsestForum.java (working copy) @@ -60,6 +60,30 @@ private Boolean isDraft; @Getter + private Boolean isAvailabilityRestricted; + + /** + * An epoch date in seconds. NOT milliseconds. + */ + @Getter + private Long openDate; + + /** + * An epoch date in seconds. NOT milliseconds. + */ + @Getter + private Long closeDate; + + @Getter + private Boolean isLocked; + + @Getter + private Boolean isPostFirst; + + @Getter + private String assocGradebookItemName; + + @Getter private List attachments = new ArrayList(); public SparsestForum(DiscussionForum fatForum, DeveloperHelperService dhs) { @@ -75,7 +99,17 @@ this.modifiedDate = fatForum.getModified().getTime()/1000; this.modifier = fatForum.getModifiedBy(); this.isDraft = fatForum.getDraft(); + this.isAvailabilityRestricted = fatForum.getAvailabilityRestricted(); + if (this.isAvailabilityRestricted != null && this.isAvailabilityRestricted) { + this.openDate = fatForum.getOpenDate() != null ? fatForum.getOpenDate().getTime()/1000 : null; + this.closeDate = fatForum.getCloseDate() != null ? fatForum.getCloseDate().getTime()/1000 : null; + } + + this.isLocked = fatForum.getLocked(); + this.isPostFirst = fatForum.getPostFirst(); + this.assocGradebookItemName = fatForum.getDefaultAssignName(); + for(Attachment attachment : (List) fatForum.getAttachments()) { String url = dhs.getServerURL() + "/access/content" + attachment.getAttachmentId(); attachments.add(new SparseAttachment(attachment.getAttachmentName(),url));