Skip to content

Commit

Permalink
Merge pull request sakaiproject#443 from pushyamig/master
Browse files Browse the repository at this point in the history
SAK-29272 drafted forums/topic is included in the /topic feed
  • Loading branch information
bethkirschner committed Apr 24, 2015
2 parents 7146835 + c1995cb commit 4b16383
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ public class DecoratedForumInfo {
private String description;
private List<DecoratedAttachment> attachments;
private Boolean isLocked;
private Boolean isDraft;

private Boolean isPostFirst;
private Boolean isAvailabilityRestricted;
private Long openDate; // An epoch date in seconds. NOT milliseconds.
private Long closeDate; // An epoch date in seconds. NOT milliseconds.
private String gradebookItemName;
private Long gradebookItemId;



public DecoratedForumInfo(Long forumId, String forumTitle,
List<DecoratedAttachment> attachments, String shortDescription,
Expand All @@ -31,11 +35,12 @@ public DecoratedForumInfo(Long forumId, String forumTitle,

public DecoratedForumInfo(Long forumId, String forumTitle,
List<DecoratedAttachment> attachments, String shortDescription,
String description, Boolean isLocked, Boolean isPostFirst,
String description, Boolean isLocked, Boolean isDraft, Boolean isPostFirst,
Boolean isAvailabilityRestricted, Long openDate, Long closeDate,
String gradebookItemName, Long gradebookItemId) {
this(forumId, forumTitle, attachments, shortDescription, description);
this.isLocked = isLocked;
this.isDraft=isDraft;
this.isPostFirst = isPostFirst;
this.isAvailabilityRestricted = isAvailabilityRestricted;
this.openDate = openDate;
Expand Down Expand Up @@ -79,7 +84,16 @@ public Boolean getIsLocked() {
public void setIsLocked(Boolean isLocked) {
this.isLocked = isLocked;
}
public Boolean getIsDraft() {
return isDraft;
}

public void setIsDraft(Boolean isDraft) {
this.isDraft = isDraft;
}



public Boolean getIsPostFirst() {
return isPostFirst;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ public class DecoratedTopicInfo {
private String description;

private Boolean isLocked;
private Boolean isDraft;


private Boolean isPostFirst;
private Boolean isAvailabilityRestricted;
private Long openDate; // An epoch date in seconds. NOT milliseconds.
private Long closeDate; // An epoch date in seconds. NOT milliseconds.
private String gradebookItemName;
private Long gradebookItemId;


public DecoratedTopicInfo(Long topicId, String topicTitle,
int unreadMessagesCount, int messagesCount, String typeUuid,
Expand All @@ -38,13 +42,14 @@ public DecoratedTopicInfo(Long topicId, String topicTitle,
public DecoratedTopicInfo(Long topicId, String topicTitle,
int unreadMessagesCount, int messagesCount, String typeUuid,
List<DecoratedAttachment> attachments, String shortDescription,
String description, Boolean isLocked, Boolean isPostFirst,
String description, Boolean isLocked, Boolean isDraft, Boolean isPostFirst,
Boolean isAvailabilityRestricted, Long openDate, Long closeDate,
String gradebookItemName, Long gradebookItemId) {

this(topicId, topicTitle, unreadMessagesCount, messagesCount, typeUuid,
attachments, shortDescription, description);
this.isLocked = isLocked;
this.isDraft=isDraft;
this.isPostFirst = isPostFirst;
this.isAvailabilityRestricted = isAvailabilityRestricted;
this.openDate = openDate;
Expand Down Expand Up @@ -100,6 +105,15 @@ public Boolean getIsLocked() {
public void setIsLocked(Boolean isLocked) {
this.isLocked = isLocked;
}
public Boolean getIsDraft() {
return isDraft;
}

public void setIsDraft(Boolean isDraft) {
this.isDraft = isDraft;
}



public Boolean getIsPostFirst() {
return isPostFirst;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ public List<?> getEntities(EntityReference ref, Search search) {
}

for (DiscussionForum forum : forums) {
if(forum.getDraft().equals(Boolean.FALSE)){
List<DecoratedAttachment> forumAttachments = decorateAttachments(forum.getAttachments());
Long forumOpenDate = null;
Long forumCloseDate = null;
Expand All @@ -390,13 +389,12 @@ public List<?> getEntities(EntityReference ref, Search search) {
forumGbItemId = gbItemNameToId.get(forum.getDefaultAssignName());
}

DecoratedForumInfo dForum = new DecoratedForumInfo(forum.getId(), forum.getTitle(), forumAttachments, forum.getShortDescription(), forum.getExtendedDescription(), forum.getLocked(),
DecoratedForumInfo dForum = new DecoratedForumInfo(forum.getId(), forum.getTitle(), forumAttachments, forum.getShortDescription(), forum.getExtendedDescription(), forum.getLocked(),forum.getDraft(),
forum.getPostFirst(), forum.getAvailabilityRestricted(), forumOpenDate, forumCloseDate, forum.getDefaultAssignName(), forumGbItemId);
List<DiscussionTopic> topics = forum.getTopics();
int viewableTopics = 0;

for (DiscussionTopic topic : topics) {
if(topic.getDraft().equals(Boolean.FALSE)){

if (forumManager.isInstructor(userId, siteId) ||
getUiPermissionsManager().isRead(topic.getId(), topic.getDraft(), forum.getDraft(), userId, siteId))
Expand Down Expand Up @@ -432,19 +430,17 @@ public List<?> getEntities(EntityReference ref, Search search) {
}

dForum.addTopic(new DecoratedTopicInfo(topic.getId(), topic.getTitle(), unreadMessages,
totalMessages, "", attachments, topic.getShortDescription(), topic.getExtendedDescription(), topic.getLocked(), topic.getPostFirst(), topic.getAvailabilityRestricted(),
totalMessages, "", attachments, topic.getShortDescription(), topic.getExtendedDescription(), topic.getLocked(), topic.getDraft(), topic.getPostFirst(), topic.getAvailabilityRestricted(),
topicOpenDate, topicCloseDate, topic.getDefaultAssignName(), topicGbItemId));
viewableTopics++;
}
}
}

// TODO this is a bit too simplistic but will do for now. better to be more restrictive than less at this point
// "instructor" type users can view all forums. others may view the forum if they can view at least one topic within the forum
if (forumManager.isInstructor(userId, siteId) || viewableTopics > 0) {
dForums.add(dForum);
}
}
}
}

Expand Down

0 comments on commit 4b16383

Please sign in to comment.