markRead(m, ureq.getIdentity());
map.put("newMessage", Boolean.TRUE);
}
// add some data now
Date creationDate = m.getCreationDate();
Identity modifier = m.getModifier();
if (modifier != null) {
map.put("isModified", Boolean.TRUE);
map.put("modfname", modifier.getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale()));
map.put("modlname", modifier.getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale()));
} else {
map.put("isModified", Boolean.FALSE);
}
map.put("title", m.getTitle());
map.put("body", m.getBody());
map.put("date", f.formatDateAndTime(creationDate));
Identity creator = m.getCreator();
map.put("firstname", Formatter.truncate(creator.getUser().getProperty(UserConstants.FIRSTNAME, ureq.getLocale()),18)); //keeps the first 15 chars
map.put("lastname", Formatter.truncate(creator.getUser().getProperty(UserConstants.LASTNAME, ureq.getLocale()),18));
// map.put("username", Formatter.truncate(creator.getName(),18));
map.put("modified", f.formatDateAndTime(m.getLastModified()));
// message attachments
OlatRootFolderImpl msgContainer = fm.getMessageContainer(forum.getKey(), m.getKey());
map.put("messageContainer", msgContainer);
List<VFSItem> attachments = new ArrayList<VFSItem>(msgContainer.getItems(new VFSItemExcludePrefixFilter(MessageEditController.ATTACHMENT_EXCLUDE_PREFIXES)));
// List attachments = msgContainer.getItems();
map.put("attachments", attachments);
if (attachments == null || attachments.size() == 0) map.put("hasAttachments", Boolean.FALSE);
else map.put("hasAttachments", Boolean.TRUE);
// number of children and modify/delete permissions
int numOfChildren;
numOfChildren = countNumOfChildren(m, threadMsgs);
Integer nOfCh = new Integer(numOfChildren);
map.put("nOfCh", nOfCh);
boolean userIsMsgCreator = ureq.getIdentity().getKey().equals(creator.getKey());
Boolean uIsMsgC = new Boolean(userIsMsgCreator);
map.put("uIsMsgC", uIsMsgC);
boolean isThreadtop = m.getThreadtop()==null;
map.put("isThreadtop", Boolean.valueOf(isThreadtop));
boolean isThreadClosed = Status.getStatus(m.getStatusCode()).isClosed();