diff --git a/src/main/java/org/olat/modules/fo/ForumController.java b/src/main/java/org/olat/modules/fo/ForumController.java index 6151dfd1ebb884031daf0869d27318024c7a394a..ba685d2ca58fccafb4eb508f79c91293053ea122 100644 --- a/src/main/java/org/olat/modules/fo/ForumController.java +++ b/src/main/java/org/olat/modules/fo/ForumController.java @@ -989,7 +989,7 @@ public class ForumController extends BasicController implements GenericEventList // single message in thread view, add message and mark as read addMessageToCurrentMessagesAndVC(ureq, m, vcThreadView, currentMessagesMap, 0, marks, stats); // init single thread list and append - sttdmodel = new ForumMessagesTableDataModel(threadMsgs, rms); + sttdmodel = new ForumMessagesTableDataModel(userManager, threadMsgs, rms); sttdmodel.setLocale(ureq.getLocale()); singleThreadTableCtr.setTableDataModel(sttdmodel); int position = PersistenceHelper.indexOf(threadMsgs, currentMsg); @@ -1265,9 +1265,9 @@ public class ForumController extends BasicController implements GenericEventList if(isHidden) { title = translate("msg.hidden") + " " + title; } - mesgWrapper[1] = new ForumHelper.MessageWrapper(title,isSticky,collator); + mesgWrapper[1] = new ForumHelper.MessageWrapper(title,isSticky,collator, f); User creator = thread.getCreator().getUser(); - mesgWrapper[2] = new ForumHelper.MessageWrapper(creator.getProperty(UserConstants.FIRSTNAME, null) + " " + creator.getProperty(UserConstants.LASTNAME, null),isSticky, collator); + mesgWrapper[2] = new ForumHelper.MessageWrapper(userManager.getUserDisplayName(creator),isSticky, collator, f); // find latest date, and number of read messages for all children // init with thread values Date lastModified = thread.getLastModified(); @@ -1297,13 +1297,13 @@ public class ForumController extends BasicController implements GenericEventList } } } - mesgWrapper[3] = new ForumHelper.MessageWrapper(lastModified,isSticky,collator); + mesgWrapper[3] = new ForumHelper.MessageWrapper(lastModified,isSticky,collator, f); //lastModified - mesgWrapper[4] = new ForumHelper.MessageWrapper(new Integer(statCounter),isSticky,collator); + mesgWrapper[4] = new ForumHelper.MessageWrapper(new Integer(statCounter),isSticky,collator, f); //marked - mesgWrapper[5] = new ForumHelper.MessageWrapper(new Integer((childCounter - readCounter)),isSticky,collator); + mesgWrapper[5] = new ForumHelper.MessageWrapper(new Integer((childCounter - readCounter)),isSticky,collator, f); // unread - mesgWrapper[6] = new ForumHelper.MessageWrapper(new Integer(childCounter),isSticky,collator); + mesgWrapper[6] = new ForumHelper.MessageWrapper(new Integer(childCounter),isSticky,collator, f); // add message itself for later usage mesgWrapper[7] = thread; tmpThreadList.add(thread); diff --git a/src/main/java/org/olat/modules/fo/ForumHelper.java b/src/main/java/org/olat/modules/fo/ForumHelper.java index 15d382b7ca67ac9635d9bedab013dc14a748467c..897b8a788c7f58627c7bba00caa7bc92d8102353 100644 --- a/src/main/java/org/olat/modules/fo/ForumHelper.java +++ b/src/main/java/org/olat/modules/fo/ForumHelper.java @@ -27,6 +27,10 @@ package org.olat.modules.fo; import java.text.Collator; import java.util.Comparator; +import java.util.Date; +import java.util.Locale; + +import org.olat.core.util.Formatter; /** * @@ -108,13 +112,17 @@ public class ForumHelper { private Comparable value; private boolean sticky; private Collator collator = Collator.getInstance(); + private Formatter formatter = Formatter.getInstance(Locale.getDefault()); - public MessageWrapper(Comparable value_, boolean sticky_, Collator collator) { + public MessageWrapper(Comparable value_, boolean sticky_, Collator collator, Formatter formatter) { value = value_; sticky = sticky_; if (collator != null) { this.collator = collator; } + if (formatter != null) { + this.formatter = formatter; + } } /** @@ -122,7 +130,10 @@ public class ForumHelper { * @see java.lang.Object#toString() */ public String toString() { - return value.toString(); + if (value instanceof Date) { + return formatter.formatDateAndTime((Date)value); + } + else return value.toString(); } public boolean isSticky() { diff --git a/src/main/java/org/olat/modules/fo/ForumMessagesTableDataModel.java b/src/main/java/org/olat/modules/fo/ForumMessagesTableDataModel.java index fddce2cda89402b9c8a5863bee6bcbea92043fc7..67d79d45d67b5f1493e46135d29b344429fafa76 100644 --- a/src/main/java/org/olat/modules/fo/ForumMessagesTableDataModel.java +++ b/src/main/java/org/olat/modules/fo/ForumMessagesTableDataModel.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Set; import org.olat.core.gui.components.table.DefaultTableDataModel; -import org.olat.core.id.UserConstants; +import org.olat.user.UserManager; /** * @author Felix Jost @@ -38,14 +38,12 @@ import org.olat.core.id.UserConstants; public class ForumMessagesTableDataModel extends DefaultTableDataModel<Message> { private Set<Long> readMsgs; + private UserManager userManager; - public ForumMessagesTableDataModel() { - super(null); - } - - public ForumMessagesTableDataModel(List<Message> objects, Set<Long> readMsgs) { + public ForumMessagesTableDataModel(UserManager userManager, List<Message> objects, Set<Long> readMsgs) { super(objects); this.readMsgs = readMsgs; + this.userManager = userManager; } public int getColumnCount() { @@ -66,9 +64,7 @@ public class ForumMessagesTableDataModel extends DefaultTableDataModel<Message> String title = m.getTitle(); return title; case 1 : - String last= m.getCreator().getUser().getProperty(UserConstants.LASTNAME, getLocale()); - String first= m.getCreator().getUser().getProperty(UserConstants.FIRSTNAME, getLocale()); - return last + " " + first; + return userManager.getUserDisplayName(m.getCreator().getUser()); case 2 : Date mod = m.getLastModified(); return mod;