Search in sources :

Example 41 with Message

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");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) SelectMessageEvent(org.olat.modules.fo.ui.events.SelectMessageEvent)

Example 42 with 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;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Message(org.olat.modules.fo.Message) FOCourseNode(org.olat.course.nodes.FOCourseNode) ICourse(org.olat.course.ICourse) Forum(org.olat.modules.fo.Forum)

Example 43 with Message

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);
}
Also used : Message(org.olat.modules.fo.Message)

Example 44 with Message

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());
    }
}
Also used : Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) ForumManager(org.olat.modules.fo.manager.ForumManager) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 45 with Message

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;
}
Also used : Message(org.olat.modules.fo.Message) Media(org.olat.modules.portfolio.Media) MessageLight(org.olat.modules.fo.MessageLight) File(java.io.File)

Aggregations

Message (org.olat.modules.fo.Message)108 Identity (org.olat.core.id.Identity)18 OLATResourceable (org.olat.core.id.OLATResourceable)16 ErrorEditMessage (org.olat.modules.fo.ui.events.ErrorEditMessage)16 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)12 Date (java.util.Date)8 HttpResponse (org.apache.http.HttpResponse)8 Test (org.junit.Test)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 ICourse (org.olat.course.ICourse)8 FOCourseNode (org.olat.course.nodes.FOCourseNode)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 PublisherData (org.olat.core.commons.services.notifications.PublisherData)5