use of org.olat.modules.fo.Message in project openolat by klemens.
the class MessageListController method doFinalizeMove.
private void doFinalizeMove(UserRequest ureq, MessageView messageToMove, Long parentMessageKey) {
if (foCallback.mayEditMessageAsModerator()) {
Message message = forumManager.getMessageById(messageToMove.getKey());
Message parentMessage = forumManager.getMessageById(parentMessageKey);
message = forumManager.moveMessage(message, parentMessage);
markRead(message);
// commit before sending event
DBFactory.getInstance().commit();
ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_MESSAGE_MOVE, getClass(), LoggingResourceable.wrap(message));
Long threadKey = parentMessage.getThreadtop() == null ? parentMessage.getKey() : parentMessage.getThreadtop().getKey();
fireEvent(ureq, new SelectMessageEvent(SelectMessageEvent.SELECT_THREAD, threadKey, message.getKey()));
} else {
showWarning("may.not.move.message");
}
}
use of org.olat.modules.fo.Message in project openolat by klemens.
the class FinishCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
FOCourseNode node = (FOCourseNode) runContext.get(SendMailStepForm.FORUM);
ICourse course = (ICourse) runContext.get(SendMailStepForm.ICOURSE);
CourseEnvironment courseEnv = course.getCourseEnvironment();
Forum chosenforum = node.loadOrCreateForum(courseEnv);
Message msg = (Message) runContext.get(SendMailStepForm.MESSAGE_TO_MOVE);
msg = forumManager.getMessageById(msg.getKey());
Message parentMessage = (Message) runContext.get(SendMailStepForm.PARENT_MESSAGE);
if (parentMessage != null) {
parentMessage = forumManager.getMessageById(parentMessage.getKey());
}
if (msg.getParentKey() == null && msg.getThreadtop() == null) {
msg = forumManager.createOrAppendThreadInAnotherForum(msg, chosenforum, parentMessage);
} else {
msg = forumManager.moveMessageToAnotherForum(msg, chosenforum, parentMessage);
}
// commit before sending event
DBFactory.getInstance().commit();
if ((Boolean) runContext.get(SendMailStepForm.SENDMAIL)) {
sendMail(ureq, wControl, runContext);
}
return StepsMainRunController.DONE_MODIFIED;
}
use of org.olat.modules.fo.Message in project openolat by klemens.
the class SelectCourseStepForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String[] threadOrComment;
Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
if (messageToMove != null && messageToMove.getThreadtop() == null) {
threadOrComment = new String[] { translate("forum.thread") };
} else {
threadOrComment = new String[] { translate("forum.comment") };
}
String[] theKeys = new String[] { "radio.foreign.course", "radio.same.course" };
String[] theValues = new String[] { translate("radio.foreign.course", threadOrComment), translate("radio.same.course", threadOrComment) };
chooseCourse = uifactory.addRadiosVertical("step.select.course", formLayout, theKeys, theValues);
chooseCourse.addActionListener(FormEvent.ONCLICK);
}
use of org.olat.modules.fo.Message in project openolat by klemens.
the class ForumArtefactHandler method prefillArtefactAccordingToSource.
/**
* @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact, java.lang.Object)
*/
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
super.prefillArtefactAccordingToSource(artefact, source);
if (source instanceof OLATResourceable) {
OLATResourceable ores = (OLATResourceable) source;
ForumManager fMgr = ForumManager.getInstance();
Message fm = fMgr.loadMessage(ores.getResourceableId());
String thread = fm.getThreadtop() != null ? fm.getThreadtop().getTitle() + " - " : "";
artefact.setTitle(thread + fm.getTitle());
VFSContainer msgContainer = fMgr.getMessageContainer(fm.getForum().getKey(), fm.getKey());
if (msgContainer != null) {
List<VFSItem> foAttach = msgContainer.getItems();
if (foAttach.size() != 0) {
artefact.setFileSourceContainer(msgContainer);
}
}
artefact.setSignature(70);
artefact.setFulltextContent(fm.getBody());
}
}
use of org.olat.modules.fo.Message in project openolat by klemens.
the class ForumMediaHandler method createMedia.
@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
Message message = null;
if (mediaObject instanceof Message) {
// reload the message
message = (Message) mediaObject;
message = forumManager.loadMessage(message.getKey());
} else if (mediaObject instanceof MessageLight) {
MessageLight messageLight = (MessageLight) mediaObject;
message = forumManager.loadMessage(messageLight.getKey());
}
String content = message.getBody();
Media media = mediaDao.createMedia(title, description, content, FORUM_HANDLER, businessPath, null, 70, author);
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
File messageDir = forumManager.getMessageDirectory(message.getForum().getKey(), message.getKey(), false);
if (messageDir != null && messageDir.exists()) {
File[] attachments = messageDir.listFiles();
if (attachments.length > 0) {
File mediaDir = fileStorage.generateMediaSubDirectory(media);
for (File attachment : attachments) {
FileUtils.copyFileToDir(attachment, mediaDir, "Forum media");
}
String storagePath = fileStorage.getRelativePath(mediaDir);
media = mediaDao.updateStoragePath(media, storagePath, null);
}
}
return media;
}
Aggregations